Last active
December 21, 2015 21:09
-
-
Save AMNDesign/6366335 to your computer and use it in GitHub Desktop.
Include custom post types in tag archive and category archive search results 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
<?php | |
//* Include custom post types in tag archive and category archive search results | |
add_filter( 'pre_get_posts', 'amn_get_posts' ); | |
function amn_get_posts( $query ) { | |
if ( ( is_tag() || is_category() ) && false == $query->query_vars['suppress_filters'] ) | |
$query->set( 'post_type', array( 'post', 'page', 'attachment', 'my_custom_post_type' ) ); | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment