Home Forums Front-end Issues Query relationship values with WPML


Query relationship values with WPML

  • Hello,

    i’m using ACF + WPML + relationship fields.

    On a city page, i do list different custom posts types ( like restaurants, hotels, etc… )

    In default language ( french (FR) ) everything is OK.

    i do list all those items by filtering meta with ID & LIKE.

    Classic query, based on ACF doc.

    		$args = array(
    				'post_type' => 'restaurant',
    				'posts_per_page' => -1,
    				'meta_query' => array(
    						'key' => 'contact_city', 
    						'value' => '"' . get_the_ID() . '"',
    						'compare' => 'LIKE'
    		$query = new WP_Query($args);
    		if ($query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
    			$title = get_the_title();
    			$permalink = get_the_permalink();
    			echo '<a href="'.$permalink.'">'.$title.'<a>';

    But when i change language, i do have 0 results displayed. ( posts are translated & published in other languages ).

    if i echo get_the_ID();

    i get the good ID for each language
    ( fr = 1104 / en = 1123 )

    If i change ‘value’ to 1104, i do have the correct results displayed in every language.

    So this mean that my relationship are all based on FR id. How can i manage this ? To set ID as current language ID, or to query ID from FR relationship?

    any idea ?

  • i found Advanced Custom Field Multilingual in other forum topics,
    but if i activate this plugin nothing changes, except that i can not query with 1104 as previously ^^

  • founded a solution here with getting original_id over here

    but if someone have a better id !

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.