Opened 9 months ago

Last modified 2 weeks ago

#21596 new enhancement

enhance wp_get_archives to support post types

Reported by: jjminkle 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)

wp_get_archives.php.patch (755 bytes) - added by jjminkle 9 months ago.
svn diff

Download all attachments as: .zip

Change History (6)

svn diff

  • Keywords has-patch added

Related/duplicate: #13462

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.

  • Cc xoodrew@… added

comment:4 follow-up: ↓ 5   ancawonka3 weeks ago

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   SergeyBiryukov2 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

Note: See TracTickets for help on using tickets.