Last active
October 7, 2016 17:52
-
-
Save ccurtin/abd4f12b6da307683cdc to your computer and use it in GitHub Desktop.
Add CPTs to main_query on archive page
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 | |
| function namespace_add_custom_types( $query ) { | |
| if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { | |
| $query->set( 'post_type', array( | |
| 'post', 'nav_menu_item', 'your-custom-post-type-here' | |
| )); | |
| return $query; | |
| } | |
| } | |
| add_filter( 'pre_get_posts', 'namespace_add_custom_types' ); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment