#51543 closed feature request (fixed)
Create is_sitemap() conditional tag
| Reported by: | MadtownLems | Owned by: | westonruter |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.1 |
| Component: | Sitemaps | Version: | 5.5 |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: | Focuses: |
Description
As people continue expanding and customizing Core's XML sitemaps, I believe an is_sitemap() conditional tag would be very helpful.
In the short term, its existence would be very useful for getting around the bug explained in #51542 (https://core.trac.wordpress.org/ticket/51542), but surely developers will find other ways to make use of it and it seems like a natural fit to be a conditional tag.
Change History (11)
This ticket was mentioned in PR #12142 on WordPress/wordpress-develop by @masteradhoc.
2 months ago
#2
- Keywords has-patch added
This patch introduces is_sitemap() as a conditional query tag and adds the $is_sitemap property to WP_Query, following the established pattern of is_robots() and is_favicon().
Trac ticket: https://core.trac.wordpress.org/ticket/51543
## Use of AI Tools
AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude Sonnet 4.6
Used for: Initial implementation scaffolding. All code was reviewed, adjusted, and tested by me.
@masteradhoc commented on PR #12142:
2 months ago
#3
@mukeshpanchal27 to make reviewing easier i split the second trac ticket to a own PR, see: https://github.com/WordPress/wordpress-develop/pull/12150
@westonruter commented on PR #12142:
2 months ago
#5
✅ New code passes PHPStan rule level 10 with the bleeding edge ruleset.
@masteradhoc commented on PR #12142:
2 months ago
#7
@westonruter thanks to @nimesh-xecurify we have now tests as well for this PR :)
#11
@
5 weeks ago
Note: The is_sitemap() function does not return true for sitemap stylesheet requests, e.g. /wp-sitemap-index.xsl.
This XSL stylesheet is referenced in the sitemap XML:
<?xml-stylesheet type="text/xsl" href="http://localhost:8000/wp-sitemap-index.xsl" ?>
I think we should remove the sitemap stylesheet from core, however.
Chrome is deprecating and removing XSLT, and other browsers are doing the same.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
The is_sitemap() conditional is now provided by https://wordpress.org/plugins/xml-sitemaps-manager/ :)