Tagged: product search
-
AuthorPosts
-
April 18, 2018 at 6:30 pm #943710
Hello Sirs,
As you can see in the screenshot, it displays two products in the search results (that’s correct), but it counts the posts which are refeing the keyword “lg” also. Is that possible to exclude the reference to the posts?
Screenshot: https://prnt.sc/j6xd41
For your reference
I have used the below filter in functions.php:add_filter(‘avia_product_slide_query’, ‘avia_product_slide_query_mod’, 10, 2);
function avia_product_slide_query_mod($query, $params) {
if(is_search()) {
$query[‘s’] = $_GET[‘s’];
}return $query;
}Customization In the Search.php below:
$more = 0;
global $posts;
$post_ids = array();
foreach($posts as $post) $post_ids[] = $post->ID;if(!empty($post_ids))
{
$atts = array(
‘type’ => ‘grid’,
‘items’ => get_option(‘posts_per_page’),
‘columns’ => 4,
‘class’ => ‘avia-builder-el-no-sibling’,
‘paginate’ => ‘yes’,
‘use_main_query_pagination’ => ‘yes’,
‘custom_query’ => array( ‘post__in’=>$post_ids, ‘post_type’=>get_post_types() )
);$blog = new avia_product_slider($atts);
$blog->query_entries();
echo “<div class=’entry-content-wrapper’>”.$blog->html().”</div>”;
}}
April 20, 2018 at 7:17 am #944462Hey nickgin,
Thank you for using Enfold.
We would like to check the modifications. Please provide the login details in the private field. I can’t find the details in your previous posts.
Best regards,
IsmaelApril 26, 2018 at 3:27 am #947019Hi Ismael,
Thank you so much for your excellent support!!
Best regards,
NickApril 27, 2018 at 1:28 pm #947923Hi,
Thank you for the update. I can’t get the Appearance > Editor panel to work. Please add this code on the functions.php file.
function ava_product_search_query($query) { if (!is_admin() && $query->is_main_query()){ if (is_search()){ $query->set('post_type','product'); } return $query; } } add_action( 'pre_get_posts', 'ava_product_search_query' );
I also noticed that you’re not using a child theme. You may want to create a backup of those modifications in case you’re planning to update the theme. Version 4.3 is now available.
Best regards,
IsmaelApril 27, 2018 at 3:26 pm #947993Hi Ismael,
It worked!!! You are great!!! Thank you so much!!
You can close this ticket.
Best regards,
NickApril 29, 2018 at 8:10 am #948559Hi Nick,
Glad Ismael could help :)
If you need further assistance please let us know.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.