WordPress.org

Make WordPress Core

Opened 6 years ago

Last modified 18 months ago

#31960 new enhancement

Archives widget li should have informative css classes

Reported by: basteln3rk Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1.1
Component: Widgets Keywords: has-patch
Focuses: template Cc:

Description

The archives widget should add classes m-item and m-item-XXXX to allow better styling and ajax functionality, as well as being consistent with other widgets (e.g. categories widget provides such classes as cat-item and cat-item-XX with ID).

Workaround: it is possible to customize the archive link getter to add the required css classes:

add_filter( 'get_archives_link', function($link_html) {
        preg_match('/m=([0-9]+)/', $link_html, $m);
        $month= $m[1];
        if ($month) {
                return preg_replace('/<li>/', '<li class="m-item m-item-' . $month . '">', $link_html); 
        }       
        else {
                return $link_html;
        }
});

Attachments (1)

31960.patch (3.3 KB) - added by umesh.nevase 6 years ago.
patch file to add classes for archive widget items

Download all attachments as: .zip

Change History (3)

@umesh.nevase
6 years ago

patch file to add classes for archive widget items

#1 @umesh.nevase
6 years ago

  • Keywords has-patch added

#2 @umesh.nevase
5 years ago

Any update on this inhancement?

Note: See TracTickets for help on using tickets.