Categories and Tags not working!

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!

Cheers

2 Answers
2

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' );

Leave a Comment