Currently Available: Need a skilled Software Developer for your next project?
Categories
WordPress

How Yoast SEO Handles Sitemaps for Custom Post Types

On a WordPress site, a custom post type (CPT) groups content beyond the built-in posts and pages, such as books or products. Yoast SEO includes a CPT in XML sitemaps when the type is eligible for search and it has eligible content. An XML sitemap is a file that lists URLs for search engines.

Yoast checks three things: whether WordPress registers the CPT as public, whether Yoast includes that content type in search results, and whether each post can appear in search results. If URLs are missing, check the Yoast sitemap index first, then inspect the CPT’s sitemap and WordPress registration.

What determines whether Yoast includes a CPT

Yoast must have XML sitemaps enabled. The CPT must also be public and have valid posts. In Yoast SEO, check Settings → Site features and confirm that XML sitemaps are on under Technical SEO. Yoast’s sitemap specification describes a sitemap for each public content type that has valid members.

Next, check the content-type setting under Settings → Content types. The Show [type] in search results? option controls whether Yoast includes that type in search results; turning it off also removes the type from the sitemap, according to Yoast’s sitemap settings documentation.

The type-level setting does not guarantee that every post appears. Yoast leaves out posts that should not appear in search results. For example, a post with a noindex directive does not qualify under Yoast’s documented sitemap rules. The same applies if its manually set canonical URL differs from its default URL, or if the post has private or password-protected status. An editor can also change a post’s search visibility in Yoast’s Advanced settings. Yoast describes these individual sitemap exclusions.

Code can also change what appears in the sitemap. Yoast provides the wpseo_sitemap_exclude_post_type filter, a code hook developers can use to exclude a post type. Yoast also provides a filter to exclude individual post IDs. If the settings look correct but the sitemap omits content, check the active theme and plugins for code that changes the sitemap.

Check the CPT’s WordPress registration

WordPress registration affects whether Yoast treats a CPT as public. The public argument to register_post_type() defaults to false. Setting it to true makes the type available to public WordPress queries by default, unless related properties are set separately. The WordPress registration reference documents these arguments.

Yoast’s custom-post-type help page says its SEO features are available when a CPT has no public statement or sets public to true. WordPress documents public as defaulting to false, so inspect the CPT’s registered settings rather than assuming that leaving out the argument makes it public. Yoast’s CPT guidance and WordPress’s registration reference do not explain every possible combination of visibility settings.

To inspect a registered CPT, use its registration key rather than its dashboard label. For example, a type registered as book:

$post_type = get_post_type_object( 'book' );

if ( $post_type ) {
    var_dump( $post_type->public );
    var_dump( $post_type->publicly_queryable );
}

Replace book with the actual key. This snippet checks the values WordPress registered at runtime, but those values alone do not confirm that Yoast will include the type. Also, has_archive controls whether WordPress enables an archive page for the CPT. It is not listed as a requirement for including individual CPT posts in Yoast’s sitemap.

Verify the sitemap index and CPT URLs

Open the sitemap index, usually at https://example.com/sitemap_index.xml, replacing the domain with the site’s own address. The index lists the individual sitemap files Yoast provides. Look for a child sitemap associated with the CPT. A CPT registered with the key book might use a filename such as book-sitemap.xml, but the live index is the authority on which files the site exposes.

Open the child sitemap and check its <loc> entries, which list the URLs. Compare those URLs with published, publicly accessible CPT posts that qualify for search results. Yoast’s functional specification describes the index and child sitemap structure, including numbered files when a sitemap is split.

If the child sitemap is missing, check whether the global sitemap feature is on and whether the CPT’s search-results setting is enabled. Then verify its effective WordPress registration and check for code that excludes the type. If the child file exists but a particular URL is absent, inspect that post’s publication and visibility status and its Yoast search-visibility setting. Also check its noindex directive, manual canonical, and any post-level exclusion.

Yoast adds an X-Robots-Tag: noindex, follow header to sitemap responses. The header tells search engines not to include the sitemap file itself in search results. It does not exclude the URLs listed in that file. Yoast’s documentation also sets the default limit at 1,000 entries per sitemap, so larger CPTs can appear across numbered sitemap files. Check the index for those files before concluding that later entries are missing.

What I'm building

Delegate tasks. Get software.

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

Email updates

Usually a new article and a few links I found interesting.

No spam. Unsubscribe with one click.

Leave a Reply

Your email address will not be published. Required fields are marked *