The native WordPress search feature by default displays pages in the search results. The feature is meant for site-wide searches, but could be annoying to users who just want to display only the posts in the search results.
I have this small code snippet working for me from day one to exclude pages from the searches. It goes in the functions.php file of your WordPress theme:
function search_tweak( $query ) {
if( $query->is_search ) {
$query->set( 'post_type', 'post&...