WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Easy way to add a space between categories? edit wp_list_categories? (5 posts)

  1. keyaspects
    Member
    Posted 3 years ago #

    Hi,
    Is there an easy way to add a space between each category listed when using <?php wp_list_categories('exclude=&title_li='); ?>

    something like? <div style="height:4px;></div>
    Thanks

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

    wp_list_categories() outputs a html list, which you can style;
    you can add padding or margins to the li element, for instance in style.css of your theme.

    li { margin: 5px 0; }

    you may need to add a few selectors before the actual li to make it selective enough and to not disturb other lists in your site.

    http://www.w3schools.com/Css/css_list.asp
    http://www.w3schools.com/css/css_margin.asp
    http://www.w3schools.com/css/css_padding.asp

  3. keyaspects
    Member
    Posted 3 years ago #

    Thanks alchymyth

    I've put the following in my style.css

    li.a {
    	margin: 15px 0px;
    	list-style-type:none;
    }

    but the following php doesn't seam to work...

    <?php wp_list_categories('exclude=&title_li=&li class="a"'); ?>

    I think I'm missing something

  4. alchymyth
    Forum Moderator
    Posted 3 years ago #

    http://codex.wordpress.org/Template_Tags/wp_list_categories

    you are using unspecified parameter.

    you may need to add a few selectors before the actual li to make it selective enough

    this refers to the code in style.css; for instance:

    #sidebar .widget_categories li { ..... }

  5. keyaspects
    Member
    Posted 3 years ago #

    Thanks , all good now

Topic Closed

This topic has been closed to new replies.

About this Topic