#55633 closed defect (bug) (fixed)
First sitemap has more URLs than expected with sticky posts
Reported by: | RavanH | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | minor | Version: | 5.5 |
Component: | Sitemaps | Keywords: | has-patch commit has-unit-tests |
Focuses: | Cc: |
Description
When a site has $x sticky posts, and more posts than $max_urls (2000 by default) then the first posts sitemap will have $max_urls + $x URLs.
Not a big issue unless there are a huge number of sticky posts and the site is running on a relatively low resource server... Still, an unexpected sitemap size and it is easily fixed by setting ignore_sticky_posts :)
<?php function wpsm_posts_query_args( $args ) { // Ignore stickyness. $args['ignore_sticky_posts'] = true; return $args; } add_filter( 'wp_sitemaps_posts_query_args', 'wpsm_posts_query_args' );
Attachments (2)
Change History (21)
#3
@
2 years ago
- Keywords has-patch needs-testing added
55633.diff adds 'ignore_sticky_posts' => true
to the default args passed to wp_sitemaps_posts_query_args
.
@RavanH can you please test this patch (I've tested on a small "play" site but would be good to test on a larger, more realistic site).
#5
@
2 years ago
- Keywords needs-testing removed
Perfect! I can confirm that the patch works on a large site. :)
#6
@
2 years ago
Thanx @RavanH !!!
@swissspidy I milestoned this for 6.1, since we're already in 6.0-beta phase. However, I then noticed that is was marked as a bug
...so technically, it could still go into 6.0. I'll let you, as a commiter, make that call.
#7
follow-up:
↓ 8
@
2 years ago
Hello there,
The patch looks good to me, but I'm not sure we really need to add a comment since it is the default behavior of the ignore_sticky_posts
argument :)
#8
in reply to:
↑ 7
;
follow-up:
↓ 13
@
2 years ago
- Keywords commit added
Replying to audrasjb:
Hello there,
The patch looks good to me, but I'm not sure we really need to add a comment since it is the default behavior of theignore_sticky_posts
argument :)
That's true, but the naming of that parameter can be very confusing to those who don't know it well...so I always find it useful to include such a comment :-)
This ticket was mentioned in Slack in #core by pbiron. View the logs.
2 years ago
#12
@
2 years ago
@SergeyBiryukov 55633.2.diff is the same as 55633.diff but adds a unit test.
#13
in reply to:
↑ 8
@
2 years ago
Replying to pbiron:
Replying to audrasjb:
Hello there,
The patch looks good to me, but I'm not sure we really need to add a comment since it is the default behavior of theignore_sticky_posts
argument :)
That's true, but the naming of that parameter can be very confusing to those who don't know it well...so I always find it useful to include such a comment :-)
Alright, 55633.2.diff looks good to me then.
This ticket was mentioned in PR #2834 on WordPress/wordpress-develop by audrasjb.
2 years ago
#14
- Keywords has-unit-tests added
Trac ticket: https://core.trac.wordpress.org/ticket/55633
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.
#15
@
2 years ago
- Owner set to audrasjb
- Resolution set to fixed
- Status changed from new to closed
In 53548:
2 years ago
#16
Committed in https://core.trac.wordpress.org/changeset/53548
#19
@
2 years ago
I've implemented this (for now, awaiting 6.1) in the plugin https://wordpress.org/plugins/xml-sitemaps-manager/
Thanx for the ticket.
I'll have to think about this a little more, but on first thought it seems to make sense to add
'ignore_sticky_posts' => true
to the default args passed towp_sitemaps_posts_query_args
.@swissspidy do you have thoughts on this?