Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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>”;
    }

    }

    #944462

    Hey 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,
    Ismael

    #947019

    Hi Ismael,

    Thank you so much for your excellent support!!

    Best regards,
    Nick

    #947923

    Hi,

    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,
    Ismael

    #947993

    Hi Ismael,

    It worked!!! You are great!!! Thank you so much!!

    You can close this ticket.

    Best regards,
    Nick

    #948559

    Hi Nick,

    Glad Ismael could help :)

    If you need further assistance please let us know.
    Best regards,
    Victoria

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.