[Resolved] Post navigation language

Home Forums Support [Resolved] Post navigation language

Home Forums Support Post navigation language

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1573174
    Enrico

    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 you

    #1573337
    Leo
    Staff
    Customer Support

    Hi there,

    Sorry not sure if I fully understand.

    So is this a translation issue?

    Let me know 🙂

    #1573426
    Enrico

    Leo,
    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.

    #1573491
    Leo
    Staff
    Customer Support

    Couple of questions, are you using a translation plugin? Is English and Italian categories by any chance?

    #1573596
    Enrico

    Yes Leo, I’m using WPML.
    All categories are translated.
    Thanks.

    #1574641
    Enrico

    I 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…

    #1574673
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    I wonder if this is a setting in WPML – have you checked with their support to see if they have any ideas?

    #1574755
    Enrico

    Hi 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.
    Enrico

    #1574772
    Enrico

    I’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.
    Enrico

    #1574778
    Leo
    Staff
    Customer Support

    Glad you’ve found the solution and thanks for reporting back!

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.