Hi @kademcconville ,
Thanks for reaching out.
There is no such option in the Layout Builder for specifying the Product into the Search Result . I would suggest you go through the following thread which may help you.
Hey Tamsin,
You can use the Search Modal element. See https://theme.co/apex/forum/t/pro-search-modal-element/107
To filter search results, please add this code in your functions.php
function product_only_search($query) {
if ($query->is_search) {
$query->set('post_type', 'product');
}
return $query;
}
add_filter('pre_get_posts','product_only_search');
Thanks.
Hi @malavkarkar ,
The is_admin() conditional tag only checks if the Dashboard or the administration panel is attempting to be displayed. Try current_user_can() instead, the code will look like the following.
function JustPostFilter($query)
{
if ($query->is_search && !current_user_can('administrator') )
{
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','JustPostFilter');
Please remember that the above code will work if copied as it is an…
Hi Andreas,
Thanks for reaching out.
There is no such option to set only a few pages for search, but you can achieve that by adding the following code into your child theme functions.php file.
The following code will set the specific page id(s) when you search on your site, and the result will come up from those pages only.
function wpb_search_filter( $query )
{
if ( $query->is_search && !is_admin() )
{
$query->set('post_type', array( 'page' ) );
$query->set('post_…
Thanks