wp_get_archives() – Get CSS selector for current month

Put the following function in your functions.php

function wpse_62509_current_month_selector( $link_html ) {
    $current_month = date("F Y");
    if ( preg_match("https://wordpress.stackexchange.com/".$current_month.'/i', $link_html ) )
        $link_html = preg_replace('/<li>/i', '<li class="current-month">', $link_html );
    return $link_html;
}

And then add the following line just before calling wp_get_archives()

add_filter( 'get_archives_link', 'wpse_62509_current_month_selector' );

You might also want to remove the filter after calling wp_get_archives() so that it doesn’t mess with other wp_get_archives() or get_archives_link() function calls.

remove_filter( 'get_archives_link', 'wpse_62509_current_month_selector' );

Leave a Comment