Skip to content Skip to sidebar

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.

Sun Mon Tue Wed Thu Fri Sat
- - 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00
- - - - - - -

Supporter timezone: America/Lima (GMT-05:00)

This topic contains 3 replies, has 3 voices.

Last updated by Andreas W. 11 months, 2 weeks ago.

Assisted by: Andreas W..

Author Posts
October 23, 2024 at 4:18 am #16319774

shilpiP

Background of the issue:
I am trying to find a way to get the post IDs for all translations of a specific post using either the post ID or the slug of a post in a given language. The goal is to efficiently retrieve related translated post IDs for content synchronization and programmatic handling.

Symptoms:
Nil

Questions:
How can I retrieve all translated versions of a post using the post_id or slug in WordPress?

October 23, 2024 at 6:03 am #16319946

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
Thanks for reaching out to WPML Support.

Before this thread gets assigned to my colleague, I'd like to offer some initial guidance or potential solutions.

To retrieve all translated versions of a post using either the "post_id" or the "slug", you can use the `wpml_object_id` hook. This hook returns the ID of the translated post or page if it exists. For more details on how to implement and use this hook, refer to the documentation linked below.

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

I hope it will help in achieving what you;re looking for. But, if you need further assistance, feel free to reach out! We'll be happy to help.

Best regards,
Prosenjit

October 24, 2024 at 5:02 am #16324217

shilpiP

I am searching any API endpoint or GraphQL query to achieve this

October 24, 2024 at 6:11 pm #16327921

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

You can use the WordPress REST API and add a language paramter at the end of your request URL.

For example:

hidden link

This return all the Spanish pages.

You can then use WPML GraphQL to query posts by ID:
https://wpml.org/documentation/related-projects/wpml-graphql/

Best regards
Andreas

The topic ‘[Closed] I need assistance with retrieving all translated versions of a post using the post_id or slug of any…’ is closed to new replies.