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 am trying to set up an image menu to show "all posts", "all videos" (custom post type: rich_media). I want to have an individual image for each post type, and by clicking it I want to show all posts in the current category of the chosen post type.

All post_types share the common categories taxonomy.

I managed to list all regular posts from current category by simply linking to current category, not sure how to do the trick with the custom post.

share|improve this question
up vote 1 down vote accepted
function add_post_type_to_archives($query) {
    if(is_archive() and empty($query->query_vars['suppress_filters'])){
        $query->set('post_type', array('post', 'rich_media'));
    return $query;
add_filter('pre_get_posts', 'add_post_type_to_archives');

For a custom post type to be shown in archives, it needs to be added to the $query. Like above. It's up to you to refine the situations where you want it added. Like:

    $query->set('post_type', array('post', 'rich_media'));

This will add the rich_media post type to the loop if the *custom_tag_query_var* is present (custom_tag_query_var archive).

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.