Active class with custom wp_get_archives HTML output
I use a filter on get_archives_link
for the HTML output and I try to reproduce the default aria-current=page
attribute on the a
tag when we are on the archive page.
if ( ! function_exists( 'o2_archives_html' ) ) :
function o2_archives_html( $link_html, $url, $text, $format, $before, $after ) {
if ( 'html' === $format )
$link_html = \tli$beforea href='$url'span class='label'span class='title'$text/span/span/a$after/li\n;
return $link_html;
}
endif; // o2_archives_html()
add_filter( 'get_archives_link', 'o2_archives_html', 10, 6 );
I would like to put an active class on the li class=active
tag when we are for example on February 2022 site.com/blog/2022/02/page/2/
.
What condition does this?
Topic wp-get-archives Wordpress
Category Web