WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How make category show as "current" in e.g. header or menu? (6 posts)

  1. danvendel
    Member
    Posted 6 years ago #

    Hi,

    I have tested a number of different blogware the past weeks, so I might recollect wrong. But I remember that when a user spcifically selects a certain category in the side menu, the name of this category shows up in the header where the blog name is otherwise, and the blog name itself moves to where the blog description is normally.

    But it's not working. In fact, there's no way a user can say which category he's in unless he's keeping perfect track of his clicks. No "current" link highlighted in the sidebar menu, no headline, no header - nothing.

    So, how can I make this obvious to the user? I'm open for any suggestion (I know a bit php and can fiddle with code if that's what it takes).

    I use version 2.3.2 and theme called "Chopati".

    TIA
    Dan

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    This is hard to answer without more specific details.

    However, most of the functions in WordPress, like wp_list_categories(), provide a CSS indicator of the current category (or whatever) when appropriate.

    If you use wp_list_categories to display a category listing, then when you're on the category archive page, you'll find that the current category being displayed automatically gets an extra CSS class of "current-cat". By styling .current-cat in your CSS, you can provide a visual indicator of what the current category is.

    There's similar indicators for wp_list_pages() and other such functions. But exactly how to make it work for a particular site depends on the site. We'd have to see the site in action, see some of the code being used to display the category list, etc.

  3. danvendel
    Member
    Posted 6 years ago #

    Thanks Otto,

    I'll look into your suggestion and see what I can do. Will get back to you.

    Dan

  4. danvendel
    Member
    Posted 6 years ago #

    Follow-up:

    Yes, I edited the stylesheet as you suggested. But not just the plain class "current-cat" but with its selector "a", i.e. I had to create class ".current-cat a".

    This was better than before. Still, if anyone reads this, I'm still looking for a way to add the current category as a headline. I'm right now looking into the plugin "WP-Sticky 1.10" and see if I can make that work the way I want it.

    Thanks.

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    dan: The single_cat_title() function will output the current category when looking at a category archive page.

  6. danvendel
    Member
    Posted 6 years ago #

    Thanks Otto.

    Added
    <?php echo "<div id=\"catTitleHeader\">";
    single_cat_title() ;
    echo "</div>"; ?>
    to the themes index.php, made a style #catTitleHeader and it works perfectly!

    Cheers,
    Dan

Topic Closed

This topic has been closed to new replies.

About this Topic