Filter if XML sitemap transient cache is enabled

#890173
  • Resolved Alper B.
    Rank Math pro

    Hi,

    For some reason, only the post-sitemap.xml shows “couldn’t fetch” in GSC. So, I have been searching the forums to see what might have caused the issue. Based on the suggestions provided here:
    https://rankmath.com/kb/exclude-sitemaps-from-caching/

    1- I excluded the sitemap from the cache plugins
    2- I flushed the sitemap cache (as shown in the video here: https://i.rankmath.com/pipRDp)
    3- I removed the RankMath transients
    4- I cleared the cache/transients etc.
    4- I created the file rank-math.php (in the child-theme) and added the following code:
    /
    **
    * Filter if XML sitemap transient cache is enabled.
    *
    * @param boolean $unsigned Enable cache or not, defaults to true
    */
    add_filter( 'rank_math/sitemap/enable_caching', '__return_false');

    First, I had the code displayed on the header of the admin panel. So, I removed the rank-math.php and added the the code directly in the functions.php (in the child-theme). The notification disappeared from the dashboard.

    However, it still exists whenever I click on RankMath>Dashboard and General Settings.

    Also, in the admin panel > Dashboard the RankMath Overview widget is all messed up! I have attached the screenshot.

    Could you please help at your earliest convenience with both issues (only post-sitemap.xml not being fetched in GSC) and also this “Filter if XML sitemap transient cache is enabled….” code being displayed messing up the dashboard widget?

    Thank you for your time!

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

    We apologize for the issues you are facing with the post-sitemap.xml not being fetched in Google Search Console (GSC) and the notification regarding the "Filter if XML sitemap transient cache is enabled" code appearing in your dashboard.

    It seems like you’ve already taken several steps to troubleshoot the sitemap issue, which is great. Here are a few additional suggestions:

    1. Check for Conflicting Plugins: Sometimes, other plugins can conflict with Rank Math. You can use the Health Check plugin to identify any potential conflicts.

    2. Verify Sitemap URL: Ensure that you are submitting the correct sitemap URL to GSC, which should be something like https://rankmath.com/wp-content/uploads/2021/09/Flush-Permalinks-Settings.jpg. If you have a static file namedsitemap_index.xml`, it could cause issues, so make sure to remove it if it exists.

    3. Flush Permalinks: Go to WordPress Dashboard → Settings → Permalinks and click on Save Changes without making any changes. This can help refresh your permalinks and might resolve the fetching issue.

    4. Check Robots.txt: Ensure that your robots.txt file is not blocking access to your sitemap. You can check this under Rank Math SEO → General Settings → robots.txt.

    Regarding the notification about the filter code appearing in your dashboard:

    • It seems that the code might still be causing an issue if it was added incorrectly. Make sure that the code is placed correctly in the rank-math.php file of your child theme and not in the header or anywhere else.
    • If you still see the notification, try removing the code from functions.php and placing it back into rank-math.php, ensuring there are no syntax errors or misplaced characters.

    If these steps do not resolve your issues, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further. Thank you for your patience, and we hope to help you resolve these issues soon!

    Alper B.
    Rank Math pro

    I also removed the code from the functions.php and still have the same issue.

    /
    **
    * Filter if XML sitemap transient cache is enabled.
    *
    * @param boolean $unsigned Enable cache or not, defaults to true
    */
    add_filter( 'rank_math/sitemap/enable_caching', '__return_false');

    and I deactivated and reactivated Rankmath plugin. Still no dice!

    Thank you!

    Hello,

    It seems that you have missed adding the opening PHP tag in the filter (Line 1)

    tag

    Please follow our guide here on how to apply the filter properly:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Regarding the issue in your GSC, please take a screenshot of your sitemap section where the error shows.

    Looking forward to helping you.

    Alper B.
    Rank Math pro

    Hello,

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

    Thank you.

    Alper B.
    Rank Math pro

    Hi,

    Yes, you are right! I missed adding the opening PHP tag in the filter (Line 1). I figured it out as soon as I created the ticket! 😏

    Now that I removed the code from the site completely, should I add it in rank-math.php (child-theme) or in functions.php (child-theme)?

    I’ve added the screenshots from GCS. Please take a look.

    Thank you for your time and help!

    Hello,

    You can add the code to either of them, but you can choose rank-math.php file so it is organized in your theme files.

    Regarding your sitemap, it seems that you’re currently using Yoast so we’re unable to check it when Rank Math is enabled.

    Looking forward to helping you.

    Alper B.
    Rank Math pro

    Hi,

    I am not using Yoast. Never installed it on this site. Rankmath is installed and connected!

    Thank you

    Hello,

    The screenshot URLs you’ve shared are returning a 404 error. Can you please share your sitemap URL with us so that we can check this again further for you?

    Meanwhile, please try to follow the steps below and see if that works for you:

    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/

    Once done, clear your website cache, remove all the submitted sitemap, and resubmit only the /sitemap_index.xml in the Search Console.

    If the issue persists, please try to follow this guideline for further troubleshooting: https://rankmath.com/kb/couldnt-fetch-error-google-search-console/

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

    Thank you.

    Hi,

    The screenshots are working on my end but regardless, I fixed the issue. The culprit was the Sitemap page.

    Thank you for your time and help.

    Hello,

    We are glad that everything has been sorted out.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

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

The ticket ‘Filter if XML sitemap transient cache is enabled’ is closed to new replies.