Month class (wordpress)

Add a current month class to the archive widget.

<?php
/**
 * Add a current month class to the archive widget.
 */
add_filter('get_archives_link', function($link_html) {
  if (is_month()) {
    $current_month = get_the_date("F Y");
    if (preg_match('/'.$current_month.'/i', $link_html)) {
      $link_html = preg_replace('/<li>/i', '<li class="current-month">', $link_html);
    }
  }
  return $link_html;
});
?>

functions.php

< toolbox