Created
May 2, 2016 02:16
-
-
Save z2015/5761ca1499f701b7a3462aa810973b42 to your computer and use it in GitHub Desktop.
WordPress搜索结果排除页面类型
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
//exlude page from search results | |
function SearchFilter($query) { | |
if ($query->is_search) { | |
$query->set('post_type', 'post'); | |
} | |
return $query; | |
} | |
add_filter('pre_get_posts','SearchFilter'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment