Created
October 11, 2017 13:14
-
-
Save igorveremsky/5330756c07222b9f671dfd456f7f46a7 to your computer and use it in GitHub Desktop.
Search only in posts Wordpress
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 | |
/* | |
* Search only in posts | |
* */ | |
function search_only_in_posts($query) { | |
if ($query->is_search) { | |
$query->set('post_type', 'post'); | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts','search_only_in_posts'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment