Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client has a custom post type called 'resources' with an accompanying custom Gutenberg block called 'resource feed'. This block is dynamic and displays data from entries in the feed. However, it does not display different content based on the selected language, showing the same content across all languages.
Solution:
We recommend using the

wpml_object_id

hook to ensure that the

$post_id

refers to the translated post in the currently active language. Here is how you can implement it:

// will return the post ID in the current language for post ID 1
echo apply_filters( 'wpml_object_id', 1, 'post' );
// will return the category ID in the current language for category ID 4. If the translation is missing it will return the original (here: category ID 4)
echo apply_filters( 'wpml_object_id', 4, 'category', TRUE );
// will return the German attachment ID for attachment ID 25. If the translation is missing it will return NULL
echo apply_filters( 'wpml_object_id', 25, 'attachment', FALSE, 'de' );

Ensure that the post has an existing translation. For further guidance, refer to the wpml_object_id documentation and the full list of WPML hooks at WPML hooks reference.

If this solution does not resolve your issue or seems outdated, please check related known issues at https://wpml.org/known-issues/, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. We highly recommend opening a new support ticket for further assistance at WPML support forum.

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 3 replies, has 0 voices.

Last updated by Rich Staats 5 days, 13 hours ago.

Assisted by: Andrey.

Author Posts
January 19, 2026 at 8:37 pm #17744108

Rich Staats

we have a custom post type called resources with an accompanying custom gutenberg block called resource feed. The resource feed block is a dynamic block that shows data from the entry in the feed. We haven't been able to figure out how to make this compatible with WPML. It shows the same content regardless of what language is selected

January 19, 2026 at 10:20 pm #17744218

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

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

Thank you for contacting WPML support.

If I understand correctly, the block you’re referring to is a dynamic block.

First, please make sure that the “resources” custom post type (CPT) is set as translatable:
• Go to WPML → Settings → Post Types Translation
• Set the “resources” CPT to Translatable

If this option is not enabled, WPML will not be able to switch the displayed resources based on the current language.

Could you please share an example of the code used to create this dynamic block? To see how the block is implemented.

I've enabled debug information for this support ticket. Please refer to this link for instructions on how to retrieve this information from your site and provide it to us: http://wpml.org/faq/provide-debug-information-faster-support/

January 20, 2026 at 2:45 pm #17747047

Rich Staats

Hey Andrey, Post Type Translations are set up correctly. Here is a link to a gist that shows the code: hidden link

This has two files, the blade template that displays the feed on the frontend, as well as the Query builder. We are using a sophisticated WP set up, but it all functions the same.

January 20, 2026 at 3:25 pm #17747199

Andrey
WPML Supporter since 06/2013

Languages: English (English ) Russian (Русский )

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

Thank you for your feedback and for sharing the code.

I’m afraid I can’t directly test or debug custom code, as this goes beyond the scope of support we provide here. However, I can offer some guidance on how to approach this with WPML.

Based on your description:
• You are retrieving post data using $post_id.
• When viewing the page in a secondary language, you should ensure that $post_id refers to the translated post, not the original one.

To achieve this, I recommend using the wpml_object_id hook, which returns the ID of an element in the currently active language:

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

// will return the post ID in the current language for post ID 1
echo apply_filters( 'wpml_object_id', 1, 'post' );
 
// will return the category ID in the current language for categoy ID 4. If the translation is missing it will return the original (here: category ID 4)
echo apply_filters( 'wpml_object_id', 4, 'category', TRUE  );
 
// will return the German attachment ID for attachment ID 25. If the translation is missing it will return NULL
echo apply_filters( 'wpml_object_id', 25, 'attachment', FALSE, 'de' );

This will allow you to correctly retrieve the translated post ID when a secondary language is active.

Please also make sure that the post has an existing translation.

For reference, here is the full list of available WPML hooks:
https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

January 22, 2026 at 1:11 pm #17754008

Rich Staats

this pointed us in the right direction. We should be able to figure it out from here.