I have a multilingual website made with WPML. I have php code to run across pages but I cannot uniquely target the page with is_page(ID) since the ID of the page changes across language domain. I need to write the code to target the page for each language.
What is the best practice to target pages across language domain?

有帮助吗?

解决方案

This code returns the post ID in the current language.

$translated_post_id = apply_filters( 'wpml_object_id', $post_id, 'post' );

So, you can use $translated_post_id in is_page.

Documentation.

 

许可以下: CC-BY-SA归因
scroll top