[wp-trac] [WordPress Trac] #34058: Proposal: wp_get_archives_object() function
WordPress Trac
noreply at wordpress.org
Wed Oct 7 10:02:19 UTC 2015
#34058: Proposal: wp_get_archives_object() function
------------------------------------------+-----------------------------
Reporter: davetgreen | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Future Release
Component: General | Version: 4.3.1
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses: template
------------------------------------------+-----------------------------
Comment (by davetgreen):
I agree @pathartl there isn't much point leveraging the existing function:
we're best introducing a brand new one. There isn't an object available
already from what I've seen, so we'd need to construct this from scratch.
@boonebgorges The example you posted is along the lines of what I was
thinking in terms of the data we need. Coming at this from a REST API
angle, the output is going to be an array of objects, JSONified, so I
would suggest that as a bare minimum we need the following properties:
`ID`, `type` (month/year), `title`, `slug` and `permalink`.
For the `month` type perhaps add a `parent` property in each object? This
might be overkill, but we could also have a `count` property for the
number of posts in that archive.
Here's an example of what I'd be expecting:
[
{
"id": 2,
"title": "2015",
"slug": "2015",
"permalink": "http://www.domain.com/2015",
"count": 300,
"parent": null
},
{
"id": 42,
"title": "October",
"slug": "2015/10",
"permalink": "http://www.domain.com/2015/10",
"count": 10,
"parent": 2
}
]
I think a discussion is worth having over methods like `get_years()` and
`get_months` as these could be quite useful.
I'm happy to get involved in terms of coding this up. I've been looked for
a way to make my first proper contribution to core so this may be the
perfect opportunity. :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34058#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list