Posted By

nmyers on 03/10/11


Tagged

wordpress customtypes


Versions (?)

wordpress show custom types in categories


 / Published in: PHP
 

URL: http://tohtml.com/php/

  1. /**
  2.  * To show custom types in categories
  3.  */
  4. add_filter('pre_get_posts', 'query_post_type');
  5.  
  6. function query_post_type($query) {
  7. if(is_category() || is_tag()) {
  8. $post_type = get_query_var('post_type');
  9. if($post_type)
  10. $post_type = $post_type;
  11. else
  12. $post_type = array('post','activities','nav_menu_item');
  13. $query->set('post_type',$post_type);
  14. return $query;
  15. }
  16. }

Report this snippet  

You need to login to post a comment.