Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If all posts were skipped, remove the sitemap post. #122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adamsilverstein
Copy link

Correct an issue where, when using the msm_sitemap_skip_post filter to exclude posts, all posts for a particular date happen to be excluded. In this case the plugin would generate an invalid/empty xml entry for the date. This fix instead skips the date/removes the sitemap cpt entry.

<urlset @xmlns:xsixmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:n="http://www.google.com/schemas/sitemap-news/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" />

The invalid sitemap then resulted in a google parsing error:
screenshot

@adamsilverstein
Copy link
Author

ps. you can reproduce the invalid xml issue by adding this code to a theme

add_filter( 'msm_sitemap_skip_post', '__return_true' );

...then regenerating the sitemaps. you will find empty sitemaps with invalid xml for dates where any post was published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant