Posted By

IronMANro on 09/20/11


Tagged

post wordpress type category custom


Versions (?)

Custom post type tags/categories archive page


 / Published in: PHP
 

URL: http://wordpress.org/support/topic/custom-post-type-tagscategories-archive-page/page/2

add this in functions.php

  1. add_filter('pre_get_posts', 'query_post_type');
  2. function query_post_type($query) {
  3. if(is_category() || is_tag() || is_home() && empty( $query->query_vars['suppress_filters'] ) ) {
  4. $post_type = get_query_var('post_type');
  5. if($post_type)
  6. $post_type = $post_type;
  7. else
  8. $post_type = array('post','articles','nav_menu_item');
  9. $query->set('post_type',$post_type);
  10. return $query;
  11. }
  12. }

Report this snippet  

You need to login to post a comment.