How to Troubleshoot WordPress Plugin and Theme Conflicts
When a WordPress site breaks after you change a plugin or theme, two extensions may be clashing with each other. A conflict…
WordPress plugin developers can control Yoast SEO XML sitemaps through dashboard settings, per-item SEO settings, and PHP filters that let plugin code change Yoast values or output. An XML sitemap lists URLs for search engines, and a sitemap index points to those individual sitemap files. These controls decide which URLs Yoast includes and how it formats them. Search engines still decide on their own whether to index a listed URL, because listing a URL does not force them to index it.
Let editors use dashboard settings for choices they own, such as hiding a post type from search results. Write PHP filters when your plugin code enforces a rule, such as excluding specific records or rewriting sitemap URLs. Register a custom sitemap with Yoast when your plugin manages URLs outside Yoast’s standard content types. The sections below explain when and how to use each approach.
Yoast ties sitemap inclusion directly to search visibility. When an editor removes a post type or a taxonomy (a way to group content under terms) from search results in the dashboard, Yoast removes that content from the sitemap. Editors can also set a single post or page to noindex, which tells search engines not to show that URL in search results. You can review these dashboard controls in Yoast’s sitemap customization guidance and the per-item option in its exclusion instructions.
Write a sitemap filter when the exclusion rule belongs in your plugin code instead of an editor’s settings. Keep search visibility in mind as you do. Yoast’s functional specification states that sitemap entries should represent public, indexable content, and it lists noindex pages and URLs with a non-default canonical as reasons for exclusion. A canonical URL is the version a site marks as the preferred address for a page.
Yoast provides separate filters to exclude individual posts, entire post types, taxonomies, authors, and taxonomy terms. The XML sitemap API documentation details what each filter passes to your callback and what you must return.
| What to exclude | Filter | Return value |
|---|---|---|
| Specific posts | wpseo_exclude_from_sitemap_by_post_ids |
Post IDs to exclude |
| A post type | wpseo_sitemap_exclude_post_type |
Boolean exclusion value |
| A taxonomy | wpseo_sitemap_exclude_taxonomy |
Boolean exclusion value |
| Authors | wpseo_sitemap_exclude_author |
Users that should remain |
| Specific taxonomy terms | wpseo_exclude_from_sitemap_by_term_ids |
Term IDs to exclude |
When you filter a post type, return the original value Yoast passes in for every type your plugin does not target. That way, your callback does not overwrite another filter’s decision:
add_filter(
'wpseo_sitemap_exclude_post_type',
function ( $excluded, $post_type ) {
if ( 'internal_record' === $post_type ) {
return true;
}
return $excluded;
},
10,
2
);
Yoast passes two arguments to this filter: the current exclusion boolean and the post-type name. Your callback must return a boolean. Follow the same pattern for the other exclusion filters by accepting the documented input, returning the documented type, and leaving unrelated content alone.
For post and term exclusions, pay attention to how your callback handles arrays returned by other plugins. Yoast documents the filters and provides examples, but it does not define a standard merge pattern when multiple callbacks modify exclusion arrays. Test how your code interacts with other callbacks in every Yoast version your plugin supports.
Use Yoast’s URL and image filters when a page belongs in the sitemap but needs modified output. wpseo_xml_sitemap_post_url passes a URL and a WP_Post object to your callback so you can change the post’s sitemap URL. Yoast also documents image filters for posts (wpseo_sitemap_urlimages), taxonomy terms (wpseo_sitemap_urlimages_term), and the front page that lists posts (wpseo_sitemap_urlimages_front_page). Your callbacks use these hooks to add image data to an array.
To change file size, use wpseo_sitemap_entries_per_page, which adjusts the maximum number of entries in each sitemap file. Yoast’s specification sets 1,000 entries per sitemap as the default and paginates overflow across up to 50,000 additional sitemaps. Those numbers only describe how Yoast builds its files; including a URL still does not guarantee that a search engine will index it.
Use wpseo_sitemap_urlset when you need to change the XML structure wrapping a sitemap’s URL entries. Yoast added this filter in Yoast SEO 22.1, released February 20, 2024. The API also documents wpseo_video_item for modifying a video sitemap entry. Check which Yoast versions your plugin supports before you rely on a hook introduced in a specific release.
If another part of your plugin already generates a sitemap file, you can use wpseo_sitemap_index to add a reference to that file inside Yoast’s sitemap index. The filter only modifies the index XML and does not generate or maintain your external sitemap. If you include a lastmod value to show when the sitemap last changed, make sure your code updates that date whenever the external sitemap changes.
If you want Yoast to serve a sitemap that your plugin generates, Yoast documents how to register a custom sitemap through the global $wpseo_sitemaps object. Call register_sitemap() during init, give it a sitemap name, and pass a callback that builds the sitemap output. This approach works well for URLs that do not belong in Yoast’s standard post, author, or taxonomy sitemaps.
Test the rendered XML sitemap in addition to your PHP callback. Check that the index points to the right sitemap files, that all listed URLs are absolute, that excluded content is missing, and that any modified URL or image shows up in the right entry. You should also test a URL marked noindex and one with a non-default canonical, since Yoast’s specification uses those conditions to decide whether a URL belongs in the sitemap.
Keep cache priming and sitemap caching separate in your mind. While Yoast generates a sitemap, the wpseo_disable_xml_sitemap_cache_priming filter disables bulk priming of post, term, and featured-image caches. Priming loads that data ahead of time. Yoast notes that this avoids running one database query per post when a site lacks a persistent object cache, though priming can conflict with some custom caching layers. This filter only affects cache priming during generation; it does not control whether a server or plugin serves a cached sitemap response.
According to Yoast’s troubleshooting guidance, Yoast has disabled its own sitemap cache by default since Yoast SEO 9.0. WordPress, other plugins, or server-level caches can still serve stale output. If your sitemap does not show a content or filter change, check those cache layers, clear or refresh their stored data, and inspect the response again. The sitemap troubleshooting page walks through these causes.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com