Forums

Highlighting Current Category in the Archive and Feeds page (3 posts)

  1. gan35h
    Member
    Posted 8 months ago #

    Hi,

    I needed a category listing in my posts page and I want the current category to be highlighted. I enabled the '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? How do I do it if the category is 'All' since the 'All' doesn't exactly have a category ID?

    Thanks!

  2. nsathees
    Member
    Posted 8 months ago #

    current category will have a class of it own. just apply the style to it!

  3. gan35h
    Member
    Posted 8 months ago #

    The styling suddenly worked out of the blue! :)

    However, a problem still remains. I have given the following arguments in the wp_list_categories function.

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

    I want the 'All' option to be visible in any category listing. However, since by default, all posts load, the styling for current_category should also apply to 'All'. However, since All does not have a category ID, I do not know how to apply the current-cat class to 'All'.

    Any suggestions?

Reply

You must log in to post.

About this Topic