limit post types on search page

djrmom

{{gist file=”functions.php” lang=”php”}}
<?php

/* limit types searched on wp search page */
add_action( ‘pre_get_posts’, function( $query ) {
if ( !is_admin() && $query->is_main_query() && $query->is_search() ) {
$query->set(‘post_type’, ‘post’);
}
} );
{{/gist}}