I'm at the final debugging stages for a major web design project I've been working on for the last 6 months.

The site itself is based on the has become a bit of a behemoth (merging 4 existing sites into 1 massive one!) with various custom post types etc...

Getting to the point - my Category and Tag archives are no longer working, if you click on a category/tag in the sidebar while in any of the blogs, rather than take you to a list of blog posts within the same category/tag, it just goes to a list of nothing:

Example blogs: http://whitewatergroup.eu/leadership-blog/

Example category/tag archive: http://whitewatergroup.eu/category/100-lessons-on-happiness/

I've based the site on this template; Carbon Light:

I've been wracking my brain for the last few weeks as how to get this working - but it's beyond me - could someone be helpful and point me in the right direction as to how I've screwed this up somehow!

I beginning to wonder if I didn't register the custom posts correctly, here's an example oh the code I used:

add_action( 'init', 'register_cpt_womens_blog' );
function register_cpt_womens_blog() {
    $labels = array(
        'name' => _x( 'Women in Business Blog', 'womens_blog' ),
        'singular_name' => _x( 'Womens Blog', 'womens_blog' ),
        'add_new' => _x( 'Add New', 'womens_blog' ),
        'add_new_item' => _x( 'Add New Womens Blog', 'womens_blog' ),
        'edit_item' => _x( 'Edit Womens Blog', 'womens_blog' ),
        'new_item' => _x( 'New Womens Blog', 'womens_blog' ),
        'view_item' => _x( 'View Womens Blog', 'womens_blog' ),
        'search_items' => _x( 'Search Women in Business Blog', 'womens_blog' ),
        'not_found' => _x( 'No women in business blog found', 'womens_blog' ),
        'not_found_in_trash' => _x( 'No women in business blog found in Trash', 'womens_blog' ),
        'parent_item_colon' => _x( 'Parent Womens Blog:', 'womens_blog' ),
        'menu_name' => _x( 'Women in Business Blog', 'womens_blog' ),
    $args = array(
        'labels' => $labels,
        'hierarchical' => false,
        'description' => 'Women in Business Blog',
        'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ),
        'taxonomies' => array( 'category', 'post_tag', 'page-category' ),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 5, 
        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'post',
    'yarpp_support' => true
    register_post_type( 'womens_blog', $args );

Hope someone out there can help me!



Category and Tag archive pages only query for the post post type. If you want custom post types to appear on those pages, you need to modify the query via pre_get_posts to add additional types.

function wpd_womens_blog_taxonomy_queries( $query ) {
    if ( ( $query->is_category() || $query->is_tag() )
        && $query->is_main_query() ) {
            $query->set( 'post_type', array( 'post', 'womens_blog' ) );
add_action( 'pre_get_posts', 'wpd_womens_blog_taxonomy_queries' );

You should use the register_taxonomy_for_object_type() to register the pre-existing taxonomies with your custom post types (leaders_blog_post, womens_blog, etc). Codex reference for register_taxonomy_for_object_type()

Ex for Womens Blog:

register_taxonomy_for_object_type('category', 'womens_blog');

That can be added to the bottom of your register_cpt_womens_blog function. Also see Pippin's post for further examples of using the register_taxonomy_for_object_type function.

  • Thanks for your help Tom Hmmm... that doesn't seem to be fixing it - I'm entering it just before register_post_type
    – harry
    Jun 16 '14 at 16:49
  • I mean, I'd have it after since the post type doesn't exist yet. Would think you'd be getting some errors/warnings if debug mode is enabled. Also possible my solution fixes an issue you don't actually have. You can write some debug code and make sure the post types have the taxonomies they need, that individual posts have the individual categories they should, etc. Jun 16 '14 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.