Excluding certain URLs with patterns from sitemap

#1060582
  • Resolved ED
    Rank Math free

    Hi all,

    First time here I have migrated from another SEO plugin. So far really good experience I must say!

    I am struggling to exclude some of the URLs in the sitemap. You will see them in the private conversations. So I am using a listing plugin called Geodirectory (GD). GD generates URLs on different patterns like:

    – a page for a specialist e.g., lawyer (Post type)
    – a page for a specialist e.g., in a city (Post type + city)
    – a page for a specialist in a category e.e., lawyer for divorce (Post type + category)

    One pattern is a page for specialist in a category in a city (Post type + category + city). So this one created around 1000 URLs without much view expectation. So I want to block them forever i.e., Rank Math should not generate any sitemap for those.

    I checked our the sitemap settings but the location + category fields are not visible.

    Can you help me how I can exclude them?

    Thanks,

    ED

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

    We apologize for the issue you are facing with excluding certain URLs from your sitemap. Thank you for sharing your experience with us!

    To exclude specific URLs or patterns from your Rank Math sitemap, you can use the Exclude Terms feature. However, since you mentioned that the location + category fields are not visible, it seems like you might need to exclude them using their IDs or by adding a custom filter.

    Here’s how you can exclude posts or pages by their IDs:

    1. Go to Rank Math SEO → Sitemap Settings.
    2. Look for the Exclude Posts field where you can enter the numerical IDs of the posts you want to exclude, separated by commas.

    To find the ID of a post, open the post in the WordPress editor and check the URL. The ID is the number after post= in the URL. For example, in yourwebsite.com/wp-admin/post.php?post=123&action=edit, the ID is 123.

    If you want to exclude a pattern (like all URLs containing certain keywords), unfortunately, Rank Math does not support regex directly in the sitemap settings. You may need to add a custom filter in your theme’s functions.php file to achieve this. Here’s an example of how to do that:

    add_filter( 'rank_math/sitemap/enable_caching', '__return_false' );

    This filter disables caching for the sitemap, but you would need to implement additional logic to exclude specific patterns based on your requirements.

    If you’re looking for a more comprehensive setup or if you’re unsure about making these changes, we recommend our professional setup service. This service ensures that your plugin setup is fully correct and adheres to the latest SEO standards. You can find more information and sign up for this service at Rank Math Services.

    If you have any further questions or need assistance with specific IDs or patterns, please reply to this ticket, and a human agent from our support team will assist you further.

    Thank you for reaching out, and we hope this helps!

    Sources:
    Rank Math Sitemap Issues and Their Fixes » Rank Math

    Hello,

    Please head over to your WP Dashboard > Rank Math > Sitemap Settings and disable the “Include in Sitemap” option for these specific post types.

    Once done, please flush the Sitemap cache by following this video screencast: https://i.rankmath.com/pipRDp

    Let us know how it goes. Looking forward to helping you.

    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 ‘Excluding certain URLs with patterns from sitemap’ is closed to new replies.