Created
September 29, 2015 08:57
-
-
Save dededey/9636c84f7e6a5cc60cb0 to your computer and use it in GitHub Desktop.
add custom post type to category pages general http://premium.wpmudev.org/blog/add-custom-post-types-to-tags-and-categories-in-wordpress/
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
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(); | |
// $post_types = array( 'post', 'your_custom_type' ); | |
$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