- This topic has 9 replies, 3 voices, and was last updated 3 years, 4 months ago by Leo.
-
AuthorPosts
-
December 9, 2020 at 9:20 am #1573174Enrico
Hi there.
I see just now that the post navigation does not work as I expected.
If you please have a look on this post you will see that the navigation shows my next/previous post in Italian language, and not my next/previous English post.
How can I fix?
Thank youDecember 9, 2020 at 11:32 am #1573337LeoStaffCustomer SupportHi there,
Sorry not sure if I fully understand.
So is this a translation issue?
Let me know 🙂
December 9, 2020 at 12:22 pm #1573426EnricoLeo,
probably you don’t understand due to my bad English, I’m sorry…
It’s so:
my blog has posts in Italian and in English, but just few Italian posts are translated in English.
I would like that in the English version the post navigation shows only the next/previous English post.
At the moment the navigation shows the posts (next/previous) in chronological order, regardless of the language.
But maybe this is not possible, I don’t know…
Thank Leo.December 9, 2020 at 12:56 pm #1573491LeoStaffCustomer SupportCouple of questions, are you using a translation plugin? Is English and Italian categories by any chance?
December 9, 2020 at 2:44 pm #1573596EnricoYes Leo, I’m using WPML.
All categories are translated.
Thanks.December 10, 2020 at 9:45 am #1574641EnricoI discover that using the main theme (not a child theme) the issue disappears.
But if I use the child theme, without any custom css, the issue is still there…December 10, 2020 at 10:20 am #1574673TomLead DeveloperLead DeveloperHi there,
I wonder if this is a setting in WPML – have you checked with their support to see if they have any ideas?
December 10, 2020 at 11:19 am #1574755EnricoHi Tom.
I found the code that causes the issue.
In functions.php file I added the following code, because I need to have tag in pages too.
This is the code:function add_taxonomies_to_pages() { register_taxonomy_for_object_type( 'post_tag', 'page' ); register_taxonomy_for_object_type( 'category', 'page' ); } add_action( 'init', 'add_taxonomies_to_pages' ); if ( ! is_admin() ) { add_action( 'pre_get_posts', 'category_and_tag_archives' ); } function category_and_tag_archives( $wp_query ) { $my_post_array = array('post','page'); if ( $wp_query->get( 'category_name' ) || $wp_query->get( 'cat' ) ) $wp_query->set( 'post_type', $my_post_array ); if ( $wp_query->get( 'tag' ) ) $wp_query->set( 'post_type', $my_post_array ); }
Do you think is possible to mantain my custom code and also fix the issue?
Thanks a lot.
EnricoDecember 10, 2020 at 11:36 am #1574772EnricoI’m sorry to be again here, but I think I solve, so I will close this ticket.
Instead that edit functions.php I added a snippet, and it seems it works well.
I add this:function add_taxonomies_to_pages() { register_taxonomy_for_object_type( 'post_tag', 'page' ); register_taxonomy_for_object_type( 'category', 'page' ); } add_action( 'init', 'add_taxonomies_to_pages' );
Thank you.
EnricoDecember 10, 2020 at 11:42 am #1574778LeoStaffCustomer SupportGlad you’ve found the solution and thanks for reporting back!
-
AuthorPosts
- You must be logged in to reply to this topic.