WordPress.org

Support

Support » Themes and Templates » Styling the Categories list

Styling the Categories list

  • Hi

    I’m wondering how to style the list of categories when you call them, ie rather than the list be outputted as ‘Category One (17)’, I’d like it to say ‘Category One……….17 entries’ etc.

    Would appreciate any help.

    Turts

Viewing 1 replies (of 1 total)
  • Michael
    Moderator

    @alchymyth

    at the example of the default theme:

    hardcoded category list in sidebar:

    <ul>
    <?php
    $variable = wp_list_categories('echo=0&depth=1&show_count=1&title_li=<h2>Categories</h2>');
    $variable = str_replace('(1)', '<span>1 entry</span>', $variable);
    $variable = str_replace('(', '<span>', $variable);
    $variable = str_replace(')', ' entries</span>', $variable);
    echo $variable;
    ?>
    </ul>

    (this is a variation of: http://codex.wordpress.org/Template_Tags/wp_list_categories#Remove_Parentheses_from_Category_Counts)

    style.css for it:

    .categories .cat-item { border-bottom: 1px dotted #06c;
    	position:relative; }
    .categories .cat-item a { height:20px;
    	position:absolute; left: 0px; top:4px;
    		background:#ffc;padding-right:8px; }
    .categories .cat-item span { height:20px;
    	position:absolute; right: 0px; top:4px;
    	background:#ffc;
    	padding-left:8px; color:#06c; font-size:9px; }
    .categories ul.children {display:none; }

    screenshot

Viewing 1 replies (of 1 total)
  • The topic ‘Styling the Categories list’ is closed to new replies.