Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Our next available supporter will start replying to tickets in about 2.79 hours from now. Thank you for your understanding.

This topic contains 1 reply, has 2 voices.

Last updated by Dražen Duvnjak 7 months, 3 weeks ago.

Author Posts
September 5, 2023 at 4:41 pm #14346461

lukasM

Hi,
im using a custom post type for store locations in 3 languages.
When i switch the site to RU im still getting 'store_country' in EN.

Do you know why?

$args = array(
'post_type' => 'stores',
'posts_per_page' => -1
);

$stores = new WP_Query($args);
$countries = array();

while ($stores->have_posts()):
$stores->the_post();
$store_country = get_field('store_country', get_the_ID());
$countries[] = $store_country //should be RU not EN;
endwhile;

September 6, 2023 at 6:48 am #14348693

Dražen Duvnjak
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello,

can you please try to use our wpml_object_id hook to get the translated ID:

- https://wpml.org/wpml-hook/wpml_object_id/

Example:

get_field( FIELD_NAME,apply_filters( 'wpml_object_id', get_the_ID(), 'page', TRUE,'en'  );

Regards,
Drazen

The topic ‘[Closed] get_field not getting the correct language’ is closed to new replies.