Created
January 5, 2019 08:50
-
-
Save Tsunamijaan/206c90629fb337ddf7f5decb8f691c28 to your computer and use it in GitHub Desktop.
Filter search results by post type
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
| function search_posts_filter( $query ){ | |
| if ($query->is_search){ | |
| $query->set('post_type',array('post','custom_post_type1', 'custom_post_type2')); | |
| } | |
| return $query; | |
| } | |
| add_filter('pre_get_posts','search_posts_filter'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment