This thread is resolved. Here is a description of the problem and solution.
Problem:
The client is managing a bilingual site with a custom post type 'News' created using Advanced Custom Fields and Elementor Pro. The archive pages translate correctly, but the author archive pages do not link properly in the language switcher, redirecting to the homepage of the opposite language instead of linking to the corresponding translated author archive page.
Solution:
We escalated the issue to our 2nd tier of support. They provided a workaround involving adding the following code to the functions.php file:
function include_custom_post_types_in_author_archive( $query ) {<br /> if ( $query->is_author() && $query->is_main_query() ) {<br /> $post_types = $query->get('post_type');<br /> if (!is_array($post_types)) {<br /> $post_types = array($post_types);<br /> }<br /> $post_types[] = 'news';<br /> $query->set('post_type', $post_types);<br /> }<br />}<br />add_action( 'pre_get_posts', 'include_custom_post_types_in_author_archive' );
After implementing this code, double-check if the issue with the language switcher on the author archive pages is resolved.
If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Should you need further assistance, please do not hesitate to open a new support ticket or visit our support forum 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 4 replies, has 2 voices.
Last updated by 1 year, 1 month ago.
Assisted by: Carlos Rojas.