Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save coffeepostal/2eb7647b6914245782bc70c180728eff to your computer and use it in GitHub Desktop.
Save coffeepostal/2eb7647b6914245782bc70c180728eff to your computer and use it in GitHub Desktop.
WordPress: Adding Custom Post Types to Tag/Category Results
// 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