wordpress show custom types in categories


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



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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.