Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hi, I’ve got the same problem. This is my workaround:

    Edit Ajaxy’s sf.php,
    1. locate the line $query = $wpdb->prepare("select... within the function sf_posts_query and replace it with the following

    if ( defined( 'POLYLANG_VERSION' ) ) {
        // This first clause is from translated-post.php:join_clause() (Polylang). I hardcoded it to include alias 'p'.
        // It should still work with
        // $join_polylang = PLL()->model->post->join_clause()
    	$join_polylang = " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = p.ID"; 
    
    	$filter_by_language = PLL()->model->post->where_clause( pll_current_language() );
    	$query = $wpdb->prepare("select * from (select $wpdb->posts.ID from $wpdb->posts where (post_title like '%%%s%%' ".($search_content == true ? "or post_content like '%%%s%%')":")")." and post_status='publish' and post_type='".$post_type."' $excludes $order_results limit 0,".$limit.") as p ". $join_polylang .  $filter_by_language . " group by p.ID",  ($search_content == true ? array($search, $search): array($search)));
    }
    else {
    	// Original code
    	$query = $wpdb->prepare("select * from (select $wpdb->posts.ID from $wpdb->posts where (post_title like '%%%s%%' ".($search_content == true ? "or 	post_content like '%%%s%%')":")")." and post_status='publish' and post_type='".$post_type."' $excludes $order_results limit 0,".$limit.") as p, ".$wpdb->prefix."icl_translations as i where p.ID = i.element_id and i.language_code = %s group by p.ID",  ($search_content == true ? array($search, $search, $wpml_lang_code): array($search, $wpml_lang_code)));
    }

    2. locate the line $query = "select * from... within the function sf_category_query and replace it with:

    if ( defined( 'POLYLANG_VERSION' ) ) {
    	$join_polylang = PLL()->model->term->join_clause();
    	$filter_by_language = PLL()->model->term->where_clause( pll_current_language() );
    	$query = "select * from (select distinct($wpdb->terms.name), $wpdb->terms.term_id,  $wpdb->term_taxonomy.taxonomy,  $wpdb->term_taxonomy.term_taxonomy_id from $wpdb->terms, $wpdb->term_taxonomy where name like '%%%s%%' and $wpdb->term_taxonomy.taxonomy<>'link_category' and $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id $excludes limit 0, ".$limit.") as t" . $join_polylang . $filter_by_language . " group by t.term_id";
    }
    else {
    	//Original code
    	$query = "select * from (select distinct($wpdb->terms.name), $wpdb->terms.term_id,  $wpdb->term_taxonomy.taxonomy,  $wpdb->term_taxonomy.term_taxonomy_id from $wpdb->terms, $wpdb->term_taxonomy where name like '%%%s%%' and $wpdb->term_taxonomy.taxonomy<>'link_category' and $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id $excludes limit 0, ".$limit.") as c, ".$wpdb->prefix."icl_translations as i where c.term_taxonomy_id = i.element_id and i.language_code = %s and SUBSTR(i.element_type, 1, 4)='tax_' group by c.term_id";
    }
Viewing 1 replies (of 1 total)