Rank Math SEO adds incorrect sitemap entries for translated homepages

#256940
  • Resolved Jesper Pallesen
    Rank Math free

    Hi,

    For some reason /hemppedia/ is added to the end of the homepage urls for all additional languages in the sitemap. They redirect to the same url without the /hemppedia/. I have talked to WPML that couldn’t find where the bug was coming from but thought it was something coming from Rankmath. Is this issue known to you and how do I fix it?

    Screenshot from sitemap generated by RankMath: https://ibb.co/TMJdync

    Best regards,
    Jesper

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    There is a known issue like this before with the WPML platform and they released a workaround for this. Could you please try downloading this plugin and let us know if the issue still persists?

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

    I hope that helps.

    Thank you.

    Hi,

    Yes, WPML support already told me to activate this plugin, but it doesn’t fix it unfortunately.

    Best regards,
    Jesper

    Hello,

    In this case, we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.

    Please do take a complete backup of your website before sharing the information with us.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Thank you.

    Hello,

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

    Thank you.

    Hello,

    We fixed the issue on your website by adding the following filter:

    
    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;
    }
    

    This removes the extra word from the slug of your pages.

    Don’t hesitate to get in touch if you have any other questions.

    Hi,

    Thanks a lot, I see it’s fixed now.

    In which file did you insert that filter?

    Best regards,
    Jesper

    Prabhat
    Rank Math agency

    Hello,

    We inserted the code in the functions.php file of your website.

    If there’s anything else that we can assist you with, please let us know.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Rank Math SEO adds incorrect sitemap entries for translated homepages’ is closed to new replies.