Sitemap Slug for Custom Post Types

#716579
  • Resolved Anonymous
    Rank Math free

    Hi, thank you for developing this wonderful SEO plugin for WordPress.

    Can you please let me know if we can use custom slug for custom post types alone. For main post the sitemap can be as it is. Only needed for custom post types. For example,

    Custom Post Type Name: Movies
    Sitemap URL: https://example.com/movies/sitemap.xml

    Please let me know if there is anything that can be done to achieve this. Please share any hooks or filters or any code customizations that I can implement.

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello, thank you for reaching out to us with your question about custom sitemap slugs for specific post types.

    To achieve a custom sitemap URL for your custom post type “Movies,” you can use the following filter to add extra URLs to the XML sitemap by type. You will need to replace {$type} with the name of your custom post type, in this case, “movies.”

    /**
     * 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/movies_content', function() {
        return '
        https://rankmath.com/wp-content/uploads/2021/04/Video-Sitemap-URL.jpg
        2022-03-01T12:00:00+00:00
        ';
    });

    By adding this filter to your theme’s functions.php file, you can customize the sitemap URL for your “Movies” custom post type.

    If you have any further questions or need additional assistance, please feel free to ask.

    Sources:
    Bulk Editing Options in the Rank Math SEO Plugin
    Using Video Sitemaps in Rank Math
    How to Create a Custom Sitemap and Include It in Rank Math » Rank Math
    How to Configure Sitemaps in Rank Math – Best Settings and Tips

    Hello,

    Thank you for contacting us and bringing your concern to our attention.

    Unfortunately, right now we don’t have this option to specifically change your custom post-type sitemap slug. You can only change your main sitemap slug by using the following filter: https://rankmath.com/kb/filters-hooks-api-developer/#change-sitemap-base

    Hope that helps and please don’t hesitate to let us know if you have any other questions.
     
    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 2 replies - 1 through 2 (of 2 total)

The ticket ‘Sitemap Slug for Custom Post Types’ is closed to new replies.