Sitemap url

#39462
  • Resolved Ray
    Rank Math free

    Hello,

    Is there any way to modify the sitemap’s post/page url?

    My theme will auto generated 2 archives pages, as wordpress default setting is that archive cannot be modified, so I ‘ve created 2 new pages and force redirect 2 archive pages to my new pages.

    However, Rankmath’s sitemap still uses the archive page url,
    that’s why I am asking…. is there anyway to modify the sitemap’s post/page url?

    Thank you!

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

    Thank you for contacting Rank Math today.

    You can change the archive URL that the plugin uses for the sitemap by making use of the following filter with some custom logic on your functions.php file:

    /**
     * Filter the URL Rank Math SEO uses in the XML sitemap for this post type archive.
     *
     * @param string $archive_url The URL of this archive
     * @param string $post_type   The post type this archive is for.
     */
    add_filter( 'rank_math/sitemap/post_type_archive_link', function( $archive_url, $post_type ){
    	return $archive_url;
    }, 10, 2 );

    Looking forward to helping you. Thank you.

    ​​​​​​

    Ray
    Rank Math free

    Thanks for the reply! That’s anice solution. Yet I am not pro at php code,
    would you be specific how to use that code?

    Old URL : example.com/1/ & example.com/2/
    New URL : example.com/new1/ & example.com/new2/

    where shall I put the url?

    Also what do the “10” and “2” mean in that code?

    Thanks!

    • This reply was modified 4 years, 8 months ago by Ray.
    • This reply was modified 4 years, 8 months ago by Ray.
    • This reply was modified 4 years, 8 months ago by Ray.
    Todd
    Rank Math free

    Hi Ray,

    I am sorry but you need basic knowledge of PHP to make it work.

    There is a simpler solution to removing something from the sitemap:
    1. Mark it as noindex:
    https://i.rankmath.com/UGciOq

    2. Exclude it from the Sitemap at WordPress Dashboard > Rank Math > Sitemap Settings.

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    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 ‘Sitemap url’ is closed to new replies.