Last active
July 21, 2016 00:07
-
-
Save coffeepostal/2eb7647b6914245782bc70c180728eff to your computer and use it in GitHub Desktop.
WordPress: Adding Custom Post Types to Tag/Category Results
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
// Adding Custom Post Types to Tag/Category Results | |
function add_custom_types_to_tax( $query ) { | |
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { | |
// Get all your post types | |
$post_types = get_post_types(); | |
$query->set( 'post_type', $post_types ); | |
return $query; | |
} | |
} | |
add_filter( 'pre_get_posts', 'add_custom_types_to_tax' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment