WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!


share|improve this question
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
up vote 2 down vote accepted

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' );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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