Forums Forums Search & Filter Pro Initial WP_Query with Polylang showing double items (EN + NL)

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #230221

    Hi Support,

    My initial WP_Query with Polylang is showing double items (EN + NL). After filtering the right items (EN or NL) per language are shown correctly.

    English: https://lacourdesparfums.com/en/products
    Dutch: https://lacourdesparfums.com/producten

    I read the documentation carefully and can’t seem to find a the right solution. I tried the following solution as a last resort:

    $queryArgs = array(
    	'post_type' => 'product',
    	'posts_per_page' => -1,
    	'orderby' => array('menu_order' => 'ASC', 'title' => 'ASC'),
    	'has_password' => false,
    	'paged' => get_query_var('paged') ? absint(get_query_var('paged')) : 1,
    	// Without this the filtering won't work:
    	//'search_filter_id' => 132846,
    );
    
    //Experiment to make the search_filter_id unique per language:
    if(pll_current_language() == 'nl') :
    	$queryArgs['search_filter_id'] = 132846;
    elseif(pll_current_language() == 'en') :
    	$queryArgs['search_filter_id'] = 187211;
    endif;
    
    $items = new WP_Query(array_merge($queryArgs));

    Could you please help me in the right direction?

    Trevor
    #230348

    As the search is set to use the WC store, it should autoswitch between the form languages, so it may be a setup issue.

    What made you initially add the 'search_filter_id' => 132846, line to the arguments, as it should not normally be needed?

    Anonymous
    #230470

    Hi Trevor, thanks for your reply. I changed the setting of the Display results method to ‘WooCommerce Shop’ and the query back to the default WooCommerce query with: while ( have_posts() ) : the_post();

    Still do I get dutch products on the english archive-product and vice versa…

    Any idea why the products are cross language shown? Without Search & Filter Pro, it works like expected.

    Ross Moderator
    #230547

    Hi Rogier

    Trevor asked me to take a look a this.

    I did some tests with Polylang and S&F and all seems to be working ok from my side.

    However I haven’t tested with WC also..

    After installing Polylang and WC, I get a notification that I should install Polylang for WooCommerce
    https://polylang.pro/downloads/polylang-for-woocommerce/

    Do you have this plugin installed?

    Thanks

Viewing 4 posts - 1 through 4 (of 4 total)