Opened 9 months ago
Last modified 2 weeks ago
#21596 new enhancement
enhance wp_get_archives to support post types
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | xoodrew@… |
Description
I needed to populate an option list of a form with the titles of custom post types. It seemed like wp_get_archives would do the trick, except there was no way to tell it to grab a post_type. So I enhanced wp_get_archives to support and additional parameter.
Attachments (1)
Change History (6)
This does not get the complete job done but might be a start. I think we really do need to be able to use custom post types with wp_get_archives.
comment:3
DrewAPicture — 3 months ago
- Cc xoodrew@… added
I think this would be very helpful, and would especially be nice for creating 404 pages and other indexes.
In the meantime, you can achieve the same effect by adding a posts_where filter before you do your wp_get_archives call, and then removing it right after.
comment:5
in reply to:
↑ 4
SergeyBiryukov — 2 weeks ago
Replying to ancawonka:
In the meantime, you can achieve the same effect by adding a posts_where filter before you do your wp_get_archives call, and then removing it right after.
wp_get_archives() doesn't call WP_Query::get_posts(), so the posts_where filter doesn't seem applicable here.
There is, however, getarchives_where filter that can be used instead:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/general-template.php#L915

svn diff