function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');
add_filter('register_post_type_args', function($args, $post_type) {
if (!is_admin() && $post_type == 'page') {
$args['exclude_from_search'] = true;
}
return $args;
}, 10, 2);
<input type="hidden" value="post" name="post_type" />
. В value
можете вписать тип поста. product, post, order и т.д<input type="hidden" value="1" name="sentence" />
<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ) ?>" >
<div class="stylevision-sear">
<div class="stylevision-sear__block">
<input class="stylevision-sear__input" type="search" value="<?php echo get_search_query() ?>" name="s" id="s site-search" placeholder="Example: what to wear to prom" aria-label="Search through site content">
<input type="hidden" value="post" name="post_type" />
<input type="hidden" value="1" name="sentence" />
</div>
<button class="stylevision-sear__btn">Search</button>
</div>
</form>