Last active
April 19, 2016 20:35
-
-
Save colormono/209a791070e34f2cfd16bae03603b7fb to your computer and use it in GitHub Desktop.
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
/** | |
* Show Custom Post Types in Category Archive Page | |
* @link: https://wpbeaches.com/show-custom-post-types-category-archive-page/ | |
*/ | |
function themeprefix_show_cpt_archives( $query ) { | |
if( is_front_page() || is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { | |
$query->set( 'post_type', array( | |
'post', 'nav_menu_item', 'custom-post-type-name' | |
)); | |
return $query; | |
} | |
} | |
add_filter( 'pre_get_posts', 'themeprefix_show_cpt_archives' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment