Unwanted page in sitemep.xml

#829555
Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    I apologize for the inconvenience you are facing with your multilanguage WordPress website’s sitemap. To exclude the unwanted page entry in your page-sitemap.xml, you can follow these steps:

    1. Add the following code anywhere in your theme’s rank-math.php file:

      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( WPMLFPObj::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;
      }
    2. Make sure to take a backup of your website’s files and database before making any changes to the code.

    By adding this code snippet to your rank-math.php file, you should be able to exclude the unwanted page entry from your sitemap. If you encounter any difficulties or need further assistance, please feel free to reach out. Thank you for bringing this to our attention.

    You can check the updated sitemap here: craiasadraganului.ro/page-sitemap.xml

    Best regards.

    Sources:
    Multilingual SEO with Rank Math SEO & WPML » Rank Math
    Why the Sitemap_Index.xml is Throwing a 404 Error » Rank Math
    Rank Math Sitemap Issues and Their Fixes » Rank Math

    Hello,

    Thank you for contacting us and sorry for any inconvenience that might have been caused due to that.

    Please follow this guide to fix the incorrect homepage URL of your secondary languages in the sitemap: https://rankmath.com/kb/multilingual-seo-wpml/#num-11-1-rankmath-seo-adds-incorrect-entries-for-translated-homepages-in-the-sitemap

    Let us know how it goes. Looking forward to helping you.

    Thank you.

    Hi

    I have added the above code to wp-content/themes/oceanwp/rank-math.php the page was still there.

    Hello,

    Please follow the steps below:

    1. Flush the Sitemap cache by following this video screencast:
    https://i.rankmath.com/pipRDp

    2. Exclude the Sitemap files of the Rank Math plugin in your caching plugin. The cache could be via a plugin or from the server. For plugins or Cloudflare, please follow this article:
    https://rankmath.com/kb/exclude-sitemaps-from-caching/

    3. Apply the following filter code to your site.

    
    add_filter( 'rank_math/sitemap/enable_caching', '__return_false');

    Here’s how you can add filter to your WordPress site:https://rankmath.com/kb/wordpress-hooks-actions-filters/

    If the issue persists after following the above steps, 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.

    Hello,

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

    Thank you.

    Hi,

    The error is still there. Can you please check?

    Hello,

    There was an additional page in the database with the post_name entry set to “home” which is why the page was appearing inside the sitemap.

    We have removed that name from the page and now the sitemap is only showing the available pages on your website.

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

    Thank you. Now the issue is fixed.

    Hello,

    We are glad to know that this issue has been resolved. Thank you for letting us know.

    This ticket will be closed now, but you can always open a new one if you have any other questions or concerns. We are here to help you with anything related to Rank Math.

    We appreciate your patience and cooperation throughout this process.

    Thank you for choosing Rank Math.

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

The ticket ‘Unwanted page in sitemep.xml’ is closed to new replies.