1

I would like to change the color of the current category in this page :

enter image description here

my code for display category is :

     <ul class="ul-cat">
            <?php wp_list_categories( array(
    'orderby' => 'id',
    'title_li' => 'Filtres :</br></br>',

) ); ?>

thank you :)

6
  • What template does this code appear on? Single post, category archive ...?
    – WebElaine
    Jul 20, 2017 at 13:46
  • in tpl_newsroom.php and category.php pls
    – sbzc
    Jul 20, 2017 at 13:47
  • Category.php makes sense but can you explain how "tpl_newsroom.php" would have a "current" category? Is it restricted to displaying 1 category's posts, have a different taxonomy?
    – WebElaine
    Jul 20, 2017 at 13:49
  • This answer should take care of category.php: wordpress.stackexchange.com/questions/121702/…
    – WebElaine
    Jul 20, 2017 at 13:50
  • If newsroom template uses custom taxonomy: haxo.it/…
    – WebElaine
    Jul 20, 2017 at 13:51

1 Answer 1

1

By default it will add current-cat class to the current category item.

If we need to change that, we can use:

'current_category'

(int|array) ID of category, or array of IDs of categories, that should get the 'current-cat' class. Default 0.

as mentioned in the dev docs for wp_list_categories() arguments:

Then we can style it as needed via CSS.

Example

For your setup:

.ul-cat .current-cat a {
     color: #aaa;
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.