I have a made a custom post type called "Member Resources" the posts under this CPT have a few taxonomies such as categories and tags.

Tags = "Diversity" Categories = "Guidance"

When I go to the following urls:



No posts appear.

Though I have set public => true on the CPT function.

Posts are displaying if you go to the Member Resources archive page though, so they are displaying, but not when you filter them by taxonomies.

Any help would be appreciated!


  • Ok, so I found this little bit of code on the codex - add_action( 'pre_get_posts', 'add_my_custom_post_type' ); function add_my_custom_post_type( $query ) { if ($query->is_main_query()) $query->set( 'post_type', array( 'member-resources' ) ); return $query; } This works a charm, so it seems. But I'm baffled why, by default my custom post types are not being shown in tags and category pages? I have even registered them in the CPT. Could anyone explain why this is? – rowefx Jan 23 '13 at 12:49
  • Further to this it now deletes my "Pages" and "Posts" content and shows only the member-resources posts in these areas? – rowefx Jan 23 '13 at 13:16

You were close with the code you posted in your comment. The issue is that you only tested for is_main_query, which will limit every query on your site to that single post type.

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

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.