Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7771285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:36:50+00:00 2026-06-01T16:36:50+00:00

I am interested in how to highlight the category in which I am present

  • 0

I am interested in how to highlight the category in which I am present – with the “current” class in the template. The problem is compounded by the fact that the list of categories is not retrieved from the database WordPress (the same place, as I understand, they are stored?), that is – directly from the HTML… How to make the following code:

code:

<ul>
    <li class="blabla">
        <a>1</a>
    </li>
    <li class="blabla">
        <a>2</a>
    </li>
    <li class="blabla">
        <a>3</a>
    </li>
</ul>

code to be dynamic, for example when I go into the category of “2” to “li” will be added to the class “current”:

code:

<ul>
    <li class="blabla">
        <a>1</a>
    </li>
    <li class="blabla current">
        <a>2</a>
    </li>
    <li class="blabla">
        <a>3</a>
    </li>
</ul>

I tried to read the codex but I have two problems – I’m not good at php and most importantly hard to read in English

I sincerely apologize for the broken English with which I asked, “that” the question

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:36:51+00:00Added an answer on June 1, 2026 at 4:36 pm

    I’m not sure if I understand your question, but based on what you said, you can use css.

    Example

    /* This will highlight your menu item gray if it has current in its class attribute*/
    .current {
        background:#555;
    }
    

    If you just want a menu of the categories, you can use the WordPress category widget. It creates a menu with a list of all the categories. If you click on the category, it will have a class of current-cat. This only happens when you are in the category filter list view, so if you click on a post with that category, it will not say ‘current-cat’.

    If you want something more specialized, then it’s still possible. Tell me if the category widget will not work for you.


    Here is the way to do it in php if you don’t want to use a widget. It does basically the same thing, but you have more freedom where you want to put it.

    This is the reference page: http://codex.wordpress.org/Template_Tags/wp_list_categories

    Basically all you need is that function. Just place this snippet of code where you want your categories to appear:

    <?php echo wp_list_categories() ?> 
    

    That should create a basic html list of all the categories. It will also set the current-cat class if you are in the category archive view.

    If you want to override the current category behavior above, you can also force the menu to select a current category based on the id of the category you select. So in this example, it will add the current-cat class to the category with id three.

    <?php echo wp_list_categories(array('current_category' => 3)) ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm interested in having a look at a small sample project that would highlight
Interested in description of your most used ASP.NET httpmodules that solved a specific problem
How do I highlight operators/parentheses/brackets/etc. in VIM? I'm not interested in coloring matching or
I am interested in logging all traffic that comes over port 443 for trouble-shooting
Not interested in any source control OR shell integration. This is basically to make
I have a menu bar that displays a set of categories in an upper
Interested in using Sphinx for my application. Planning to install their latest version which
I'm interested in building something that requires a table sorting plugin. Best way to
I'm interested in having a UIViewController that supports all orientations and cleanly uses two
Interested how to do it programmatically, not export table data once (there are tools

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.