Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter carst

    (@carst)

    I agree. The syntax is off. Normally you either use a meta_query, or you use a meta_value, not both. I will check with my co-worker who wrote this. Thanks for you support, it looks like a ‘problem solved’ from my end.

    Thread Starter carst

    (@carst)

    I have found the culprit in the theme that causes this. It is indeed a pre_get_posts hook. Strangely enough it is called through ‘add_filter’ and not through ‘add_action’ like it should be.

    The function modifies the meta_query by changing order and order_by parameters. However it looks like this achieves something which we can now add through Relevanssi Premium.

    function product_search_results_first($query) {
    	if (is_admin() || !$query->is_search()) {
    		return $query;
    	}
    
    	$query->set('meta_query', [
    		'relation' => 'OR',
    		[
    			'key'     => '_wi_course_education_type',
    			'value'   => 'opleiding',
    			'compare' => 'LIKE',
    		],
    		[
    			'key'     => '_wi_course_education_type',
    			'value'   => 'e-learning',
    			'compare' => 'LIKE',
    		],
    		[
    			'key'     => '_wi_course_education_type',
    			'value'   => 'opleiding',
    			'compare' => 'NOT EXISTS',
    		],
    	]);
    	$query->set('orderby', 'meta_value');
    	$query->set('order', 'DESC');
    
    	return $query;
    }
    Thread Starter carst

    (@carst)

    Yes, it sounds unusual. I’m wondering if there is a pre_get_posts hook that might cause a problem. I will check this.

    Locally (with PHP warnings on) I still see these messages:

    Notice: Undefined index: key1 in /public/app/plugins/relevanssi/lib/sorting.php on line 360
    Notice: Undefined index: key2 in /public/app/plugins/relevanssi/lib/sorting.php on line 360
    • This reply was modified 4 years ago by carst.
    Thread Starter carst

    (@carst)

    Thanks for the fix. The sorting is the default setting (Relevance).

    The problem happens whenever I search for a term with a hyphen that is within the index. These queries do not show up in the Search log. Any search for a term with a hyphen that is not within the index goes through successfully.

    Thread Starter carst

    (@carst)

    Thanks for your answer. I was trying to work around the fact that Polylang does not automatically translate attachments, by loading the attachments from an original post. But I gather from your answer this is not possible?

    I already have posts in English, and need to translate these in Dutch. For now I would just like to get the images attached to the English post, when showing the Dutch post. I have been doing this in WPML and I expected Polylang to behave the same.

    Is there some kind of filter (pre_get_posts for instance) which Polylang uses to automatically load posts in the current language? Can I disable this?

    I tried setting the PLL_AUTO_TRANSLATE option to false, but this has no effect.
    On the other hand, if I turn of the option for translating media in the settings, it does work. This is not ideal for me – in the future I might want to be able to translate media captions in some cases, – but it could be a solution.

    Going back to WPML would be the other option, although I prefer the minimalism and simplicity of Polylang.

    Thread Starter carst

    (@carst)

    Also, from the uploader I will only see media in the same language as the post I’m looking at.

    No problem here BTW. Just stating the obvious.

Viewing 6 replies - 1 through 6 (of 6 total)