Opened 3 weeks ago
Closed 13 days ago
#64304 closed enhancement (fixed)
Archives filters: add new filter to allow customizing the limit for the queries to fetch archives
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | minor | Version: | 1.2 |
| Component: | Posts, Post Types | Keywords: | has-patch has-unit-tests |
| Focuses: | performance | Cc: |
Description
wp_get_archives already comes with 2 filters allowing one to customize some of the aspects of the queries to fetch archives on a site:
getarchives_whereallows you to customize the WHERE clausegetarchives_joinallows you to customize the JOIN clause
I think it would be useful to add a new filter, to allow customizing the LIMIT clause as well. In some environments, with sites with lots of posts with longform content, some of those queries can be really resource-intensive.
Until we have proper pagination for wp_get_archives (see #30994), I think it would make sense to allow admins to customize the LIMIT clause in some scenarios.
Change History (10)
This ticket was mentioned in PR #10552 on WordPress/wordpress-develop by @jeherve.
3 weeks ago
#1
#2
@
3 weeks ago
- Milestone changed from Awaiting Review to 7.0
- Owner set to westonruter
- Status changed from new to reviewing
@westonruter commented on PR #10552:
2 weeks ago
#5
Something that just came to mind: instead of introducing a filer specifically for the limit arg, what if there was a getarchives_args filter instead which filters the $parsed_args? This would be similar to other such filters like:
@jeherve commented on PR #10552:
2 weeks ago
#6
instead of introducing a filer specifically for the
limitarg, what if there was agetarchives_argsfilter instead which filters the$parsed_args?
This would work ; I suppose it would then not be consistent with the existing filters for the archives though.
@westonruter commented on PR #10552:
2 weeks ago
#7
I think that's OK. The other filters are explicitly lower-level for manipulating the SQL, whereas this limit filter is really just a subset of filtering all of the parsed args.
@jeherve commented on PR #10552:
2 weeks ago
#8
I just pushed a new commit to try that.
@jeherve commented on PR #10552:
2 weeks ago
#9
Any thoughts about placement of the filter before or after the
$parsed_argsare collected?
I thought about it too, and figured it may be nice to have the filtering happen before, so we still come out with a consistently formatted $parsed_args.
wp_get_archivesalready comes with 2 filters allowing one to customize some of the aspects of the queries to fetch archives on a site:getarchives_whereallows you to customize theWHEREclausegetarchives_joinallows you to customize theJOINclauseI think it would be useful to add a new filter, to allow customizing the
LIMITclause as well. In some environments, with sites with lots of posts with longform content, some of those queries can be really resource-intensive.*