CPT REWRITE IN SITEMAP

#1059377
  • Resolved Louise Briquet
    Rank Math free

    Hi, i have created a CTP with this rewrite ‘rewrite’ => array(
    ‘slug’ => ‘formations/%typeformation%’
    ) where %typeformation% is a taxonomy term.

    Problem is that this url : https://mysite.fr/formations/%typeformation%/ appears in my sitemap and even with this hook add_filter(‘rank_math/sitemap/entry’, function($url, $type, $object) i can’t remove it, can you help me with this ? Thanks.

Viewing 1 replies (of 1 total)
  • Hello,

    I apologize for the issue you are facing with the custom post type (CPT) rewrite in your sitemap. It seems that the URL with the taxonomy term is being included in the sitemap, and you’re having trouble removing it using the provided filter.

    To address this, you can try modifying your filter function to specifically check for the URLs you want to exclude. Here’s an example of how you might adjust your code:

    add_filter('rank_math/sitemap/entry', function($url, $type, $object) {
        // Check if the URL contains the specific slug you want to exclude
        if (strpos($url['loc'], '/formations/') !== false) {
            return null; // Return null to remove this entry from the sitemap
        }
        return $url; // Return the URL if it doesn't match
    }, 10, 3);

    This code checks if the URL contains /formations/ and removes it from the sitemap by returning null. Make sure to place this code in your theme’s functions.php or in the rank-math.php file as appropriate.

    If this does not resolve your issue, please reply to this ticket with your site URL so that we can assist you further. Thank you for raising this concern!

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

    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 ‘CPT REWRITE IN SITEMAP’ is closed to new replies.