Removing posts from sitemap affects sitemap pagination?
-
Hi I’ve been using the following code to exclude certain posts within a set category from the sitemap:
add_filter('wpseo_sitemap_entry', 'exclude_post_in_categories', 10, 3); function exclude_post_in_categories($url, $type, $post ) { $categories = array('category-slug'); if(has_category($categories, $post->ID)) { return false; } return $url; }
However whilst it works, it results in each post sitemap (i.e. post-sitemap1.xml , post-sitemap2.xml) each having a random number of posts listed, and in some cases none – I wasn’t sure if this would cause issues with the search engines / was good practice?
From what I gather Yoast calculates the total number of posts, works out how many post sitemaps are required, and then removes the excluded posts leaving several sitemaps virtually empty? Is there anyway for Yoast to remove all excluded posts before calculating how many sitemaps are required (so there are no empty/blank sitemaps created?)
I’ve tried the
wpseo_sitemap_entries_per_page
filter to see if this resets the count, but this doesn’t solve the issue?Thanks, Joey
- The topic ‘Removing posts from sitemap affects sitemap pagination?’ is closed to new replies.