Make WordPress Core

Opened 12 months ago

Last modified 12 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's profile 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 = '&#8211;';

        $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.


12 months ago
#1

  • Keywords has-patch added

This ticket was mentioned in Slack in #core by sh4lin. View the logs.


12 months ago

Note: See TracTickets for help on using tickets.