Search code examples
wordpresswp-list-categories

Bolding parent categories in wordpress


I'm using a theme in wordpress where there's a search form to display posts based on the categories selected.

I have the categories falling into place by the following code:

    <option value="1">Parent category</option>
    <option value="2">&nbsp;&nbsp;subcategory</option>
    <option value="3">&nbsp;&nbsp;subcategory</option>
    <option value="4">&nbsp;&nbsp;subcategory</option>

My goal is to bold the parent category. I've checked all my theme files if i an edit this, tried adding a CSS class which i could target, but clearly its a query, which i cannot seem to configure.

Can anybody let me know how i could bold the parent category? Many thanks for your time!


Solution

  • If you know the option value of the parent category you can just write CSS like this:

    option[value="1"] {
      font-weight: bold;
    }
    

    Slightly more detail and proof of concept here:

    https://jsfiddle.net/h6y23ge1/1/