Opened 8 months ago
#64458 new enhancement
Add ability to set different renders based on sitemap type
| Reported by: | mboynes | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Sitemaps | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
I'm working on a plugin that extends the core sitemaps functionality to add a News Sitemap. One area that got a little hacky was overriding the core Renderer. Ideally, this would work exactly like how the Providers work, extending WP_Sitemaps_Registry to also manage renderers. They could similarly be keyed by a name, and if WP_Sitemaps::render_sitemaps() has no renderer for the sitemap type, the current renderer could be used as a fallback.
This would facilitate adding other sitemap types as discussed in #51016 and offers an alternative approach to what was discussed in GitHub.
Adding a new Renderer would then look something like:
add_action( 'wp_sitemaps_init', function ( $wp_sitemaps ) { $wp_sitemaps->registry->add_renderer( 'video', new My_Video_Sitemap_Renderer() ); } );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)