سؤال

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 مع الإسناد
لا تنتمي إلى wordpress.stackexchange
scroll top