highlight current category (4 posts)

  1. izc99
    Posted 8 years ago #


    i created a dynamically highlighted menu on the sidebar as described at http://codex.wordpress.org/Dynamic_Menu_Highlighting - no problem so far. next, i introduced the is_category(); function next to is_page(); and it's working fine as well (like e.g. "/wordpress/category-one")...
    until i open the categories' single posts (like e.g. "/wordpress/category-one/123"): then, the highlightning in the sidebar-menu disappears.

    any idea where i'm wrong?

    - maybe a problem with my permalink-structure? (currently: /%category%/%post_id%)
    - or is the is_category(); function not the right way to do it?
    - or maybe i have to work with category templates as described at http://codex.wordpress.org/Category_Templates ?

    hm... maybe someone has a hint for me, that would be great!

    best, chris

  2. BPartch
    Posted 8 years ago #


    I use this for the same purpose.

    $post = $wp_query->post;
    if ( (is_single() && in_category('1')) )
    /* single category one pages */
    { $current = 'category 1'; }
    elseif ( (is_single() && in_category('2')) )
    /* single category 2 pages */
    { $current = 'category 2'; }
    elseif ( (is_single() && in_category('3')) )
    /* single category 3 pages */
    { $current = 'category 3'; }

  3. moshu
    Posted 8 years ago #

    The above is NOT the case for "is_category". For that link only the "is_single" is true.

  4. izc99
    Posted 8 years ago #

    thanks for your help, now it works fine!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.