wpml sitemap link structure / question indexing

#193999
  • Resolved Sall
    Rank Math free

    Hello,

    i have WPML installed together with Rankmath. The Main Language is English and the Homepage is under https://domain.com

    1. In the Sitemap the English URL is correct:
    https://domain.com/

    The Translated Version has URL , for Example https://domain.com/cs/

    In the Sitemap the URL is displayed like:
    https://domain.com/cs/home/

    When clicking the Link in the Sitemap, i get redirected to https://domain.com/cs/

    Can you please let me know, if this is correct, should the Link in the Sitemap not be https://domain.com/cs/ ??

    2. Regarding indexing. When i set the Main Language Page (Default Language) to index, are than automatically all other Languages when translated set to index?

    Thx
    br

Viewing 8 replies - 1 through 8 (of 8 total)
  • Cris
    Rank Math business

    Hello,

    Thank you for bringing this to our attention and apologies for the inconvenience caused.

    I’m not sure if I understand the first question correctly. Please correct me if I’m wrong.
    From what I understand, your https://domain.com/cs/home/ link is redirecting to https://domain.com/cs/ which shouldn’t, correct?

    I tried visiting the https://domain.com/cs/home/ link but I wasn’t able to replicate it since it was showing as https://domain.com/cs/home/ still.

    Also, have you tried refreshing your website permalinks? If not yet, please try to do so and see if that would help fix the issue.

    If the issue persists, you may try clearing the cache on your WordPress dashboard and see if that would make a difference.

    Regarding your second question, setting the main language to default would reflect other translated languages as well.

    For more information, you may visit the link below:
    https://wpml.org/documentation/getting-started-guide/language-setup/

    Please let us know how it goes so we can investigate further.

    Happy to help!

    Cheers,

    Sall
    Rank Math free

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Sall
    Rank Math free

    Hi Cris,

    thanks for your reply.

    For example, the translated Language Homepage Link is https://domain.com/cs/ and in the Sitemap under Pages is the Link displayed as https://domain.com/cs/home/

    I resaved Permalinks / and cleared Caches.

    I send you the Link in PM:

    thx
    br

    Brian
    Rank Math free

    Hello,

    Thank you for getting back to us.

    Upon checking your sitemap, I was able to replicate your issue here where the URL, yourdomain.com/cs/home/ redirects to yourdomain.com/cs/ which indeed should be the correct URL within the sitemap.

    This is a known issue from the WPML platform and they recently released a workaround for the issue. To resolve this you need to be using the WPML SEO glue plugin that they recently released here:

    https://wpml.org/compatibility/2021/04/wpml-seo-plugin-better-integration-with-seo-plugins/

    Hope this helps resolve this.

    Please let us know if you have any other questions for us.
    Thank you.

    Sall
    Rank Math free

    Hello Brian,

    thanks for your information. I downloaded and installed the WP SEO Glue Plugin on my Development Site yet first. Activated the Plugin, resaved Permalinks. I checked afterwards on Dev the Sitemap but the Links Structure for the Translated Home Pages is still domain.com/cs/home/

    Is there now anything else to do in Rankmath / WPML to get the correct Link Structure / Rankmath compatibility?

    Thx
    br

    Sall
    Rank Math free

    Hi, this is the actual situation, when I check my sitemap, it looks like this where the links

    http://www.mywebsite/sk/home
    http://www.mywebsite/cs/home
    http://www.mywebsite/hu/home

    and if go to the classic editor, the first option that appear is the title of the page, in this case Home, and if I translate it in the the other languages will appear in the link: http://www.mywebsite/sk/home but instead if put a space and save it it will remove the the end of the link and it will appear like this: http://www.mywebsite/sk/ ( which is what I want…)

    the question is, if I should do it like this? or withe plugin you recommended?

    let me know

    Sall
    Rank Math free

    Hello,

    I fixed the issue with the following code in functions.php

    if ( 'page' === get_option( 'show_on_front' ) ) {
        add_filter( 'rank_math/sitemap/entry', 'compsupp_5514_filter_sitemap_home_page_entry', 10, 3 );
    }
    function compsupp_5514_filter_sitemap_home_page_entry( $url, $type, $post ) {
        global $sitepress;
        static $wpml_home_urls = null;
        static $frontpage_translations = null;
        static $default_frontpage_id = null;
        if ( ! $wpml_home_urls ) {
            $active_languages = $sitepress->get_active_languages();
            $wpml_home_urls   = [];
            foreach ( $active_languages as $code => $language ) {
                $wpml_home_urls[ $code ] = $sitepress->language_url( $code );
            }
            $default_frontpage_id   = get_option( 'page_on_front' );
            $frontpage_trid         = $sitepress->get_element_trid( $default_frontpage_id, 'post_page' );
            $frontpage_translations = array_map( \WPML\FP\Obj::prop( 'element_id' ), $sitepress->get_element_translations( $frontpage_trid, 'post_page' ) );
        }
        if ( in_array( $post->ID, $frontpage_translations ) && $post->ID !== $default_frontpage_id  ) {
            $language_code = array_search( $post->ID, $frontpage_translations );
            $url['loc']    = $wpml_home_urls[ $language_code ];
        }
        return $url;
    }
    

    Thx
    br

    Hello,

    Thank you for the update.

    We are glad that this issue is already resolved, and we appreciate you sharing the code that fixed your site.

    If you have any other concerns, please don’t hesitate to contact us anytime by creating a new ticket to assist you further with anything else.

    Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)

The ticket ‘wpml sitemap link structure / question indexing’ is closed to new replies.