Create new custom post and post category of same name

You are way off, if you say that wp_publish_post() has been renamed to {$new_status}_{$post->post_type}. The latter actually is a hook, while the former is a function. Where the latter is part of the former, because it’s part of wp_insert_post. The hook {$new_status}_{$post->post_type} is part of wp_transition_post_status() – additionally see the source. You might want to … Read more

Including all post id’s of a custom post type into an array

Save yourself a loop with get_posts and ‘fields’ => ‘ids’. // Default Query function do_query($args = null) { $default_args = array( ‘numberposts’ => -1, ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘fields’ => ‘ids’, ); if (null !== $args && !empty($args)) $args = array_merge($default_args, $args); else $args = $default_args; return get_posts($args); } // Customize Query $post_ids … Read more

Best way to specify “article type” in URL

here’s a way to add article type with tags. First we add the taxonomy to our post add_action(‘init’, ‘article_type_init’); function article_type_init() { if (!is_taxonomy(‘article_type’)) { register_taxonomy( ‘article_type’, ‘post’, array( ‘hierarchical’ => FALSE, ‘label’ => __(‘Article Type’), ‘public’ => TRUE, ‘show_ui’ => TRUE, ‘query_var’ => ‘article-type’, ‘rewrite’ => true ) ); } } Than we hook … Read more

WordPress 3.9 not using custom template

Since I don’t have your theme I can’t find what causing this problem, but this should definitely solve your problem for now Create content-{post_type}.php file and add your custom-post. in the index.php add the below code above <?php get_template_part( ‘templates/content’, ‘format’); ?> <?php if(!in_array(get_post_type(), array(‘post’, ‘page’, ‘attachment’, ‘nav_menu_item’, ‘revision’))) ?> <?php get_template_part( ‘content’, get_post_type()); ?> … Read more

Categories and tags for custom post types

You need to create taxonomies specific to your post type using register_taxonomy instead of using the taxonomies argument when registering the post type. http://codex.wordpress.org/Function_Reference/register_taxonomy // categories register_taxonomy( ‘project_categories’, ‘projects’, array( ‘label’ => __( ‘Categories’ ), ‘rewrite’ => false, ‘hierarchical’ => true, ‘capabilities’ => array( ‘edit_terms’ => ‘manage_categories’ ) ) ); // tags register_taxonomy( ‘project_tags’, ‘projects’, … Read more

Reworking function for counting custom post type posts count

You have a couple of problems with your code customtaxonomy=$mytaxonomy is incorrect. First of all, there is no parameter called customtaxonomy in get_posts. Secondly, your syntaxing is wrong. If you make use of a varaible, your syntaxing should look like this ‘post_type=myposttype&customtaxonomy=’ . $mytaxonomy . ‘&posts_per_page=-1’ You should make use of a proper tax_query to … Read more

Template to list categories in custom taxonomy

I managed to sort this using: <?php $category_ids = get_all_category_ids(); ?> <?php $args = array( ‘orderby’ => ‘slug’, ‘parent’ => 0, ‘taxonomy’ => ‘servicecats’ ); $categories = get_categories( $args ); foreach ( $categories as $category ) { echo ‘<li><img src=””/><a href=”‘ . get_category_link( $category->term_id ) . ‘” rel=”bookmark”>’ . $category->name . ” . ” . … Read more