Plugin: exclude admin-only CPTs from WP sitemaps + SEO docs#6
Open
datengraben wants to merge 4 commits into
Open
Plugin: exclude admin-only CPTs from WP sitemaps + SEO docs#6datengraben wants to merge 4 commits into
datengraben wants to merge 4 commits into
Conversation
Adds RSS 2.0 feed capability for the public-facing custom post types (cb_item, cb_location, cb_timeframe) so users can subscribe to new posts and edits in any feed reader. Architecture: - src/Service/RssFeed.php — lightweight, modular service with no external dependencies. Follows the iCalendar service pattern: initRewrite() registers the rewrite rule, getFeedUrl() returns the subscription URL, renderFeedXml() is the pure (testable) XML generator, and isValidPostType() gates access to only public CPTs. - URL pattern: /?commonsbooking_rss=1&commonsbooking_rss_type=cb_item - Controlled by the new `rss_feed_enabled` checkbox in Advanced Options. - Bookings and restrictions are intentionally excluded (private data). Tests (31 tests, 44 assertions — red/green TDD): - tests/php/Service/RssFeedTest.php covers post type validation, feed URL generation, RSS 2.0 XML structure, channel metadata, item fields (title, link, pubDate, guid, description), empty feed, and settings gate. https://claude.ai/code/session_012vsbFakgmvud1An9fMknfe
cb_restriction and cb_map are public CPTs (needed for front-end rendering) but are admin configuration objects with no value for search indexing. Adds a wp_sitemaps_post_types filter to remove them from the sitemap — compatible with WP core (5.5+), Yoast SEO, and RankMath, all of which honour this filter. cb_item and cb_location are explicitly left in: they are public content that users and search engines should be able to discover. https://claude.ai/code/session_012vsbFakgmvud1An9fMknfe
Explains what CommonsBooking does automatically (which post types are included/excluded from sitemaps and why), recommends Yoast SEO or RankMath for full control, documents the core WP sitemap URLs, and covers single-post exclusion and a note on structured data. https://claude.ai/code/session_012vsbFakgmvud1An9fMknfe
8d5600f to
eb5e3dc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cb_restrictionandcb_mapfrom WordPress sitemaps viawp_sitemaps_post_typesfilter — compatible with WP core (5.5+), Yoast SEO, and RankMathcb_itemandcb_locationremain in the sitemap (public content).phpunit.result.cacheto.gitignoreWhy
cb_restrictionandcb_map?Both are registered
public => true(needed for front-end rendering) but are admin configuration objects with no value for search indexing. Without this filter they appear in the sitemap by default.Why no code for Yoast / RankMath?
No reimplementation needed — both plugins read WP's post type registration and respect
wp_sitemaps_post_types, so a single filter covers all three cases.Test plan
PluginTest::testSitemapPostTypesFilterExcludesAdminCptspasses greencb_restrictionandcb_mapabsent from/wp-sitemap.xmlon a test sitecb_itemandcb_locationpresent in/wp-sitemap-posts-cb_item-1.xmland/wp-sitemap-posts-cb_location-1.xmldocs/en/documentation/advanced-functionality/sitemaps-and-seo.mdhttps://claude.ai/code/session_012vsbFakgmvud1An9fMknfe