WordPress.org

Ready to get started?Download WordPress

Forums

Styling the Categories list (2 posts)

  1. Sean Turtle
    Member
    Posted 4 years ago #

    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

  2. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic