Looking a Filter to exclude posts by ID from the Sitemap

#1033909
Viewing 1 replies (of 1 total)
  • Hello,

    We apologize for the issue you are facing. To exclude specific posts from the Rank Math sitemap by their IDs, you can use the following code snippet in your theme’s functions.php file:

    /**
     * Filter to exclude specific post IDs from the XML sitemap.
     *
     * @param array $exclude_ids Array of post IDs to exclude.
     * @return array Modified array of post IDs to exclude.
     */
    add_filter( 'rank_math/sitemap/exclude_posts', function( $exclude_ids ) {
        // Add the IDs of the posts you want to exclude
        $exclude_ids[] = 1; // Replace 1 with the ID of the post you want to exclude
        $exclude_ids[] = 2; // Add more IDs as needed
        return $exclude_ids;
    });

    In this code, replace 1 and 2 with the actual IDs of the posts you wish to exclude from the sitemap. You can find the post ID in the URL when editing a post in WordPress, as shown in our documentation.

    If you need further assistance or have any other questions, please reply to this ticket, and a human agent from the Rank Math Support team will assist you. Thank you for raising this concern!

    Sources:
    How to Configure Sitemaps in Rank Math – Best Settings and Tips

    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 ‘Looking a Filter to exclude posts by ID from the Sitemap’ is closed to new replies.