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.

This topic contains 7 replies, has 2 voices.

Last updated by Radu 3 years, 12 months ago.

Assisted by: Radu.

Author Posts
April 8, 2020 at 1:55 pm #5866467

Christian

Tell us what you are trying to do?
Query custom field of a default language post and display on any language

How would I go about doing this?

Is there any documentation that you are following?
nope

Is there a similar example that we can see?
nope

What is the link to your site?
hidden link

April 9, 2020 at 10:34 am #5874991

Radu

Hey Christian,

Thank you for reaching out to the WPML support!

Can you tell me how is this custom field created, please? Are you using ACF to create it? I'm asking this because, if you're just trying to get the translated value of a custom field, ACF is gonna serve the translated version automatically.

You can find some more info about ACF with WPML right here:
https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/

I just need a few more details about how this custom field is created and what's the query that you want to use.
Usually, in order to filter the results of the query (like getting the posts, for example, using WP_Query) and get the translated version, you need to use

'suppress_filters' => false,

on the query.

Thanks,
Radu

April 9, 2020 at 5:39 pm #5878501

Christian

Hi, thanks for the swift response. I am using the get_/update_/delete_post_meta(...) methods in my custom plugin to create a bunch of fields. Then in one of the fields I use a shortcode that generates a pie chart. My aim is to just set this shortcode once in the default language post version in this single field and have it displayed across all other languages also. I thought there ought to be a way to put something into the post template - Best C

April 12, 2020 at 7:47 pm #5892817

Radu

Hey Christian,

The get_post_meta function has the ID as the first parameter. In this case, have you tried to get the ID of the translated post using this WPML hook:
https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/#hook-605256

then use it for getting the meta for that post? You can find some examples of how you can use the hook under the Some basic examples section.

Thanks,
Radu

April 15, 2020 at 4:43 pm #5915833

Christian

Thanks, I'll try that now

April 15, 2020 at 5:34 pm #5916109

Radu

Hey Christian,

No worries. Take your time, give this a try, and tell me how this works for you.

Thanks,
Radu

April 24, 2020 at 1:03 pm #5986739

Christian

sorry, i did not have time to look at this until now and could not figure it out. Is there a hook or combination that does something like this: get_id_of_current_post_default-language-equivalent

April 27, 2020 at 6:37 am #5999375

Radu

Hey Christian,

You can look at all the WPML hooks available right here:
https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

You can try to use this hook:
https://wpml.org/wpml-hook/wpml_object_id/

in order to get the ID of a post in another language. I think that this is what you'd like to do through get_id_of_current_post_default-language-equivalent.

Thanks,
Radu

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.