Last active
August 7, 2016 19:08
-
-
Save stuartduff/3608310 to your computer and use it in GitHub Desktop.
seacrh filter posts only
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
// Search filter returning posts only, not pages | |
function sd_limit_search_results_post_type( $query ) { | |
if ( $query->is_search ) { | |
$query->set( 'post_type', 'post' ); | |
} | |
return $query; | |
} | |
add_filter( 'pre_get_posts', 'sd_limit_search_results_post_type' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment