Make WordPress Core

Opened 5 months ago

Last modified 4 months ago

#63929 new defect (bug)

WordPress sitemap not indexing correctly when custom post types are used

Reported by: abbuabbu's profile abbuabbu Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords: reporter-feedback
Focuses: Cc:

Description

While testing WordPress 6.6 on a live environment, I noticed that the sitemap generated via wp-sitemap.xml is not indexing custom post types correctly.

Steps to reproduce:

Install a fresh WordPress 6.6 setup.

Register a custom post type (e.g., [cement_price]cementsprice.coms) via register_post_type().

Publish at least 10 posts under this custom post type.

Visit the sitemap (/wp-sitemap.xml).

Expected result:
All published custom post type entries should appear in the sitemap.

Actual result:
Some custom post type entries are missing from the sitemap, even when published.

Example Environment:
This issue was first noticed on https://cementsprice.com/

while running tests on cement price listings. The environment is:

WordPress 6.6

PHP 8.1

Nginx 1.22

No caching plugins enabled

Additional Notes:
Deactivating all plugins and switching to the Twenty Twenty-Five theme does not resolve the issue. It looks like the core wp_sitemaps_get_server() function might not properly register custom post types in all cases.

Type: defect (bug)
Severity: normal
Version: 6.6
Component: General
Contributor Focuses: rest-api, performance, seo

Change History (1)

#1 @gautam23
4 months ago

  • Keywords reporter-feedback added

Reproduction Report

Description

This report validates whether the issue can be reproduced. Since the only current officially supported version is the last major release of WordPress, I tested it on trunk.

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.28
  • Server: nginx/1.27.5
  • Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
  • Browser: Chrome 140.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins: None activated
  • Plugins:
    • Simple CPT 1.1.0
    • Test Reports 1.2.0
    • WP Dummy Content Generator 4.0.0

Actual Results

  1. ❌ Error condition does not occur (not-reproduced).

I can see the CPT and its posts in the sitemap.

Additional Notes

  • Verified custom post type registration arguments (public, has_archive, show_in_rest) in relation to sitemap inclusion.
  • Debugged WP_Sitemaps_Posts::get_object_subtypes to see why CPT is being excluded.
  • Tested permalink‑rewrite flush to ensure CPT routing correct for sitemap
  • Reviewed hooks/filters (e.g. wp_sitemaps_posts_query_args) for unintended exclusion of CPT posts
  • Checked sitemap pagination logic to see if missing posts fall into pages not being generated properly.
  • Test multiple CPT configurations: with and without archive, hierarchical, REST support, etc., verifying sitemap inclusion..

All in all, make sure that the public argument is true while you register the custom pot-type.

Note: See TracTickets for help on using tickets.