Created
May 4, 2020 19:17
-
-
Save vfontjr/34e15b09173e75b262de7902f0ae27f9 to your computer and use it in GitHub Desktop.
Source code for https://victorfont.com/add-cpts-to-wordpress-searches/
This file contains 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 | |
if ( ! is_admin() && $query->is_main_query() && $query->is_search ) { |
This file contains 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 | |
dd_filter('pre_get_posts', 'vmf_filter_search'); | |
function vmf_filter_search($query) { | |
if ( $query->is_search ) { | |
$query->set( 'post_type', array('post', 'page', 'portfolio') ); | |
}; | |
return $query; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment