This thread is resolved. Here is a description of the problem and solution.
Problem:
You are trying to get hreflang tags to render on your public custom post that has a custom post status, but they are not appearing as expected.
Solution:
We recommend adding the following code to your functions.php file to fix the issue with post status affecting WPML hreflangs:
/**<br /> * Fix post status issue for WPML hreflangs.<br /> * <br /> * @link wpmlsupp-11719<br /> */<br />add_filter('wpml_head_langs', function($args){<br /> $change_post_status = function( $post_status ) {<br /> //Change dormant to actual custom post status.<br /> if ($post_status === 'dormant') {<br /> return 'publish';<br /> }<br /><br /> return $post_status;<br /> };<br /><br /> add_filter('get_post_status', $change_post_status);<br /><br /> add_filter('wpml_hreflangs', function($args) use ($change_post_status){<br /> remove_filter('get_post_status', $change_post_status);<br /> return $args;<br /> });<br /><br /> return $args;<br />});
After implementing this code, please verify if the hreflang tags are correctly rendering for your posts.
If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your case, we highly recommend checking related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If further assistance is needed, please open a new support ticket.
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 4 replies, has 2 voices.
Last updated by 1 year, 2 months ago.
Assisted by: Osama Mersal.