开发者

Highlighting current-cat in the Archive, Feeds page of Wordpress

开发者 https://www.devze.com 2023-04-04 20:49 出处:网络
I needed a category listing in my posts page and I want the current category to be highlighted. I enabled th开发者_JS百科e \'All\' category, so consequently, I want the \'All\' also to be highlighted

I needed a category listing in my posts page and I want the current category to be highlighted. I enabled th开发者_JS百科e 'All' category, so consequently, I want the 'All' also to be highlighted when I'm viewing the posts page. So I used the codex and got the following script running.

My script is:

<cat>
<ul>
<?php wp_list_categories('show_option_all=All&hide_empty=0&title_li=&current_category=All'); ?>
</ul>
</cat>

Do I have to run an IF conditional on my archive.php file to get the category ID and highlight it using CSS class 'cat.current-cat'? How do I do it if the category is 'All' since the 'All' doesn't exactly have a category ID?

Thanks!


The wp_list_categories function by default sets the class "current-cat" to the current category. You should just have to add some CSS to your page to make the "current-cat" different than the others.

EDIT:

You can try setting current_category to 1 in the arguments passed to the function.

0

精彩评论

暂无评论...
验证码 换一张
取 消