Special format for current category (8 posts)

  1. WP_Rookie
    Posted 11 years ago #


    I want to highlight the current category in my template (i.e. formatting a category bold, when a user sees the corresponding post). Until now, I only saw examples based on is_category (hard-coded category-id).

    How can I accomplish this dynamically (without hard-coded Id's)?



  2. moshu
    Posted 11 years ago #

    You have to be a bit more specific. Which template? A good theme has usually 5-8-10 of them :)
    You mean to have the category name in bold? Where? In the sidebar menu or ...?
    "When a user sees the post..." - you mean on a single post view? archive view? category listing view?

  3. WP_Rookie
    Posted 11 years ago #

    Sorry for the inconvenience... here are the missing details.
    I designed a custom Theme based on Kubrick's and added a Link Bar at the top of the page (as seen in Wuhan's Theme). This link bar contains links to my categories.
    When a User is in Category Listing view, the current category in the bar should be formatted in bold.
    I added the code for the Link Bar to header.php.

  4. moshu
    Posted 11 years ago #

    You may want to take a look at this page in the Codex:

  5. nateomedia
    Posted 11 years ago #

    Maybe you're looking for something like this:

    <?php if ( is_category('8') ) { echo " class=\"active\""; } ?>

    You could insert this statement into a <li> tag or <a> tag to create an "active" stylesheet that would highlight the correct menu item.

  6. Syllani
    Posted 11 years ago #

    Hmm. I found this thread when searching for what I'm trying to do... it's similar, but not quite. ;)

    I have a sidebar with lists of categories, subcategories. What I'd like to do is have the category of a post be highlighted in the sidebar when looking at a post in "single-post view". (Hope I'm being clear.)

    To list the categories in the sidebar I am using:

    <?php wp_list_cats('hide_empty=0&exclude=1'); ?>

    But for the life of me I can't figure out what I'd need to do to achieve the above-mentioned functionality. Any help would be greatly appreciated. :)

  7. martin_h
    Posted 11 years ago #

    I have the same problem: if I use "is_category('1')" in the header.php in "single-post view", it says: no category.

    The question is: how can i highlight the category of a single-post-view.

  8. amanzi
    Posted 10 years ago #

    I recently fixed this by editing the list_cats function which is called by the wp_list_cats function. Check my post here: http://wordpress.org/support/topic/47919

Topic Closed

This topic has been closed to new replies.

About this Topic