Opened 4 years ago
Closed 4 years ago
#50571 closed defect (bug) (fixed)
Homepage missing in the sitemap
Reported by: | Chouby | Owned by: | swissspidy |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | 5.5 |
Component: | Sitemaps | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
On a fresh install,
- Unpublish the sample page to make sure that no page is published.
- Go to the sitemaps index.
There is no entry for pages as we could expect. But as the hompepage is listed in the list of pages, that means that the homepage is not indexed.
The issue is because the method WP_Sitemaps_Posts::get_max_num_pages()
returns 0 when there are no pages.
Attachments (4)
Change History (13)
This ticket was mentioned in Slack in #core-sitemaps by swissspidy. View the logs.
4 years ago
This ticket was mentioned in Slack in #core-sitemaps by swissspidy. View the logs.
4 years ago
#4
@
4 years ago
My initial thought was more like this:
$min_num_pages = ( 'page' === $post_type && 1 === $page_num && 'posts' === get_option( 'show_on_front' ) ) ? 1 : 0;
#5
@
4 years ago
I've added a patch with your approach @swissspidy but I excluded the 1 === $pagenum as that variable isn't available in this function. There's also no $paged in there to know if we're on the first page. However, the check against 'page' === $post_type and the max($min_num_pages, $query->max_num_pages) should cover us
Minimum 1 sitemap for pages.