Created
August 6, 2013 06:46
-
-
Save ChangJoo-Park/6162612 to your computer and use it in GitHub Desktop.
Wordpress has search function, this function's result is page and post, etc. I need only posts, So add this function in the "function.php"
Just Copy & Paste
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
/* only search post */ | |
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