Add url to sitemap

#11563
  • Resolved Andrea Marucci
    Rank Math free

    Hello there’s a way to include in the sitemap some url of pages (external to wordpress) so that the final sitemap can include also these urls?

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

    Thank you for contacting Rank Math today.

    You can make use of the following filter to add extra URLs to the sitemap:

    /**
     * Filter to add extra URLs to the XML sitemap by type.
     *
     * Only runs for the first page, not on all.
     *
     * @param string $content String content to add, defaults to empty.
     */
    add_action( 'rank_math/sitemap/{$type}_content', function() {
      
    });
    function rank_math_add_custom_dynamic_url( $urls ) {
        $urls .= '
            http://www.mysite.com/dynamic-category1/
            2019-02-22T18:02:24+00:00
        ';
    
        $urls .= '
            http://www.mysite.com/dynamic-category2/
            2019-02-22T18:02:24+00:00
        ';
    
        return $urls;
    }

    Looking forward to helping you. Thank you.

    ​​​​​​

    Where do I’ve to put this code? And what does mean “Only runs for the first page, not on all.”

    The page I’d like to include in the site map are not done within wordpress but are single html pages.

    Hi Andrea,

    Thanks for the follow up.

    The code should go on your theme’s functions.php file. This line means that the links will be added to the first page and not to the sub-sitemaps.

    The HTML pages should be able to work as well as long as you follow the same structure as the one shown on the example.

    I hope this info helps. 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 3 replies - 1 through 3 (of 3 total)

The ticket ‘Add url to sitemap’ is closed to new replies.