Trouble with sitemap hook

#729920
  • Resolved Anonymous
    Rank Math free

    Hello,

    We have a plugin that manages before and afters. We have successfully used your hooks to pass info from our system to your tool. However, we are having trouble listing our plugin’s sitemap in your sitemap_index.xml.
    add_filter( 'rank_math/sitemap/index', function( $xml ) {
    $xml .= '
    <sitemap>
    <loc>https://fulldress.wpengine.com/bragbook-sitemap.xml</loc>
    <lastmod>2020-09-14T20:34:15+00:00</lastmod>
    </sitemap>';
    return $xml;
    }, 11 );

    This is the code we used based on your support docs. Is anything obviously wrong here? Are there other methods I should try? is there a way to do this through the UI rather than through filters?

Viewing 1 replies (of 1 total)
  • Hello,

    We apologize for the inconvenience you’re experiencing with listing your plugin’s sitemap in our sitemap_index.xml. Based on the code snippet you’ve provided, it seems that the filter hook you’re using is incorrect. The correct filter hook to add links in the new sitemap is ‘rank_math/sitemap/{$type}/content’, not ‘rank_math/sitemap/index’.

    You can use the following code to add your custom sitemap link:

    add_filter( 'rank_math/sitemap/custom/content', function() {
        return '
    
    
                    https://rankmath.com/kb/fix-sitemap-issues/
                    2020-09-14T20:34:15+00:00
    
            ';
    } );

    Please replace the ‘custom’ in the filter hook with the type of sitemap you are adding. After adding this code to your theme’s functions.php file, your custom sitemap link should be included in the sitemap_index.xml.

    If you prefer a UI-based method, unfortunately, at the moment, adding custom sitemaps can only be done through filters. However, we are continuously working on improving our user interface, and your feedback is valuable to us.

    If you have any further questions or need additional assistance, please feel free to reach out. We’re here to help!

    Sources:
    How to Create a Custom Sitemap and Include It in Rank Math » Rank Math
    Rank Math SEO Filters and Hooks for Developers – Rank Math
    Rank Math Sitemap Issues and Their Fixes » Rank Math
    Why the Sitemap_Index.xml is Throwing a 404 Error » Rank Math

    This is an automated reply from Rank Math Support Bot. If you need further assistance, please reply to this topic and a human support agent will reply to you shortly.

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

The ticket ‘Trouble with sitemap hook’ is closed to new replies.