Custom post type tags/categories archive page


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.