Created
May 12, 2014 13:00
-
-
Save imvision/a8f6c54dedb5e645f86a to your computer and use it in GitHub Desktop.
Show custom post types on Tag, Archive, Author pages
This file contains hidden or 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
<?php | |
// Add custom post types on Tag, Category, Author archive pages | |
add_filter('pre_get_posts', 'query_post_type'); | |
function query_post_type($query) { | |
if(is_category() || is_tag() || $query->is_author) { | |
$post_type = get_query_var('post_type'); | |
if($post_type) | |
$post_type = $post_type; | |
else | |
$post_type = array('post','resource','user-post'); // replace cpt to your custom post type | |
$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