Can someone help with simple conditional class on <li>?
-
Hi folks,
I’ve had specific categories in a sidebar using the code below and WP would automatically insert the class “current-cat” so it was easy to style the current li.
I’ve mixed in tags now but the current-cat does not get inserted for tags. I’ve searched but can’t find an answer.
<li class="cat-group">Blah Blah</li> <ul class="cat-list"> <?php wp_list_categories('include=10,20,30,40&orderby=order&show_count=1&title_li='); ?>
The code snippet below works fine – with the exception of no current class. I’ve tried creating my own conditional statement that would insert a class if the tag was the current one – but all my attempts failed. Can someone help or point me in the right direction? Thank you.
<li class="cat-group">Blah Blah <ul class="cat-list"> <?php $tags = get_tags(array( 'orderby' => 'order', 'order' => 'ASC', 'include' => '10,20,30,40' ) ); foreach ($tags as $tag) { echo ' </li> <li><a>term_id) . '" rel="tag">' . $tag->name . '</a> (' . $tag->count . ')</li> '; } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Can someone help with simple conditional class on <li>?’ is closed to new replies.