Opened 16 months ago
Last modified 16 months ago
#58442 new enhancement
Add parameters for the wp_get_archive function that allows to filter the archive for particular years and months.
Reported by: | sh4lin | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | has-patch |
Focuses: | template | Cc: |
Description
Right now there is no way to get the monthly archive for particular year
<?php // This is what will separate dates on weekly archive links. $archive_week_separator = '–'; $sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $parsed_args['post_type'] );
In order to do that we have to use the filter to change the where clause as below.
<?php if ( ! empty( $parsed_args['in_year'] ) ) { $year = absint( $parsed_args['in_year'] ); $sql_where .= sprintf( ' AND YEAR(post_date) = %1$d', $year ); } return $sql_where;
I am suggesting here to add optional argument that can filter the months for a particular year and weeks for particular month likewise.
Change History (2)
This ticket was mentioned in PR #4535 on WordPress/wordpress-develop by @sh4lin.
16 months ago
#1
- Keywords has-patch added
This ticket was mentioned in Slack in #core by sh4lin. View the logs.
16 months ago
Note: See
TracTickets for help on using
tickets.
Trac ticket: https://core.trac.wordpress.org/ticket/58442#ticket