• Im creating a side navigation menu using the wp_list_categories function. However, the styling created by that is causing the number of posts to display on a 2nd line. I think thats due to the function using the default

    • style instead of my own. The function reference says to use the li.cat-item { … } CSS selector but I dont know how to implement that in the current CSS style sheet I have. The site is https://www.fire-emsgear.com if you need to see an example of the problem.
Viewing 2 replies - 1 through 2 (of 2 total)
  • it seems to be caused by the float:left; in this style in style.css of your theme:

    .sidenav ul li a{ float:left; width:95%; padding:4px 3%; color:#000;}

    try and remove it.


    if you want the count to be part of the link, then it gets a bit more complicated; (leave the style as it is)
    try to add something like this to functions.php of your theme:

    add_filter('wp_list_categories', 'cat_count_inline_link');
    function cat_count_inline_link($output) {
    $output = str_replace('</a> (',' (',$output);
    $output = str_replace(')',')</a> ',$output);
    return $output;
    }

    https://codex.www.ads-software.com/Plugin_API/Filter_Reference
    https://codex.www.ads-software.com/Template_Tags/wp_list_categories

    it will output your structure for all the wp_list_categories() in your theme, where ‘show post count’ is ticked.

    Thread Starter glibby

    (@glibby)

    Thanks! Oddly enough removing the float:left didn’t fix it properly but the additional functions code did the trick. Thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Styling wp_list_categories?’ is closed to new replies.