문제

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