Add active class on Archives Widget in wp
We have worked a lots of wordpress blog but in default wordpress blog archives, there is no option for active link. If we are using Archives Widget in wp So we are unable to identify the active archives. So there is an option to add active class on Archives Widget in wordpress.
Below is a code that copy and paste in a functions.php file. So active class will visible on Archives Widget. So by using css you can able to apply a active effect on it.
Php Code
function theme_get_archives_link ( $link_html ) { global $wp; static $current_url; if ( empty( $current_url ) ) { $current_url = add_query_arg( $_SERVER['QUERY_STRING'], '', home_url( $wp->request ) ); } if ( stristr( $link_html, $current_url ) !== false ) { $link_html = preg_replace( '/(<[^\s>]+)/', '\1 class="current"', $link_html, 1 ); } return $link_html; } add_filter('get_archives_link', 'theme_get_archives_link');
If you like a post and if you think this is helping for your qouestionaire so like our social media page and stay connected with us with regular basis update.
Post a Comment