Created
April 16, 2017 22:13
-
-
Save douglasanro/06fb9283a73c0de76318c8ff6b65a9c4 to your computer and use it in GitHub Desktop.
Add WordPress CPT to category and tag archives
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
<?php | |
/* ---------------------------------------------------------------------------- | |
* Add CPT to category and tag archives | |
* ------------------------------------------------------------------------- */ | |
function simple_add_custom_types( $query ) { | |
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { | |
$post_types = get_post_types(); | |
$query->set( 'post_type', $post_type ); | |
return $query; | |
} | |
} | |
add_filter( 'pre_get_posts', 'simple_add_custom_types'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment