Last active
July 21, 2020 17:04
-
-
Save markdeafmcguire/54d48d1b87acd3ec6d30a317ae3ec939 to your computer and use it in GitHub Desktop.
Add filter to check for tag 'cpacc' before running query to include CPT 'drafts' in archive loop
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
// ADD FILTER TO SHOW CPT IN TAG ARCHIVES | |
add_filter( 'pre_get_posts', 'tag_archives_show_cpts' ); | |
function tag_archives_show_cpts( $query ) { | |
if( is_tag('') && | |
empty( $query->query_vars['suppress_filters'] ) ) { | |
$query->set( 'post_type', array( 'post', 'nav_menu_item', 'drafts')); | |
return $query; | |
} | |
} | |
// Adapted From Source: https://wpbeaches.com/show-custom-post-types-category-archive-page/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment