Created
March 22, 2013 03:43
-
-
Save spencejs/5218798 to your computer and use it in GitHub Desktop.
Add Post Type To Category Archives In Wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add Post Type To Category Archives | |
add_filter('pre_get_posts', 'query_post_type'); | |
function query_post_type($query) { | |
if(is_category() || is_tag()) { | |
$post_type = get_query_var('post_type'); | |
if($post_type) | |
$post_type = $post_type; | |
else | |
$post_type = array('nav_menu_item','post','private_post'); // replace private_post to your custom post type, Leave nav_menu_item where it is! | |
$query->set('post_type',$post_type); | |
return $query; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment