rank_math/sitemap/entry is not doing anything

#884766
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    The code you shared will not work for our sitemap as the hook rank_math/sitemap/entry will only allow you to modify in coming URLs to be added to the sitemap.

    Here’s an example code you can use to insert alternate tag to the sitemap:

    add_filter( 'rank_math/sitemap/url', function( $output, $url ) {
    	$lang   = '<xhtml:link rel="alternate" hreflang="de-ch" href="' . htmlspecialchars( $url['loc'] ) . '" />';
    	$lang   = str_repeat( "\t", 1 ) . $lang . "\n";
    	$output = str_replace( '</url>', $lang . '</url>', $output );
    
    	return $output;
    }, 10, 2 );

    You may edit the code to your liking.

    Hope that helps.

    Hello,

    Beside flushing the sitemap caches in our sitemap settings, please try following the steps below to update the sitemap:

    1. 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/

    2. 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/

    Let us know how that goes.

    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 2 replies - 1 through 2 (of 2 total)

The ticket ‘rank_math/sitemap/entry is not doing anything’ is closed to new replies.