[resolved] Extra Space in Category List (5 posts)

  1. aptdesignonline
    Posted 5 years ago #


    I'm using some standard PHP to output the Category List below each post title.

    I've tried two different lines of code to output this:
    <span class="cat-links">Category:<?php printf(get_the_category_list(',') ) ?></span>
    <span class="cat-links">Category:<?php the_category(', '); ?></span>

    However, when a post is in two categories, both codes output an extra space before the comma that separates the categories. So it looks like this:

    This post is in: Category 1 , Category 2

    Could someone tell me what they think might be going on? Thanks!

  2. annedorko
    Posted 5 years ago #


  3. aptdesignonline
    Posted 5 years ago #

    Ah, the site is http://www.kaykenyon.com


  4. Michael
    Part-Time Forum Moderator
    Posted 5 years ago #

    this extra space comes from the style.css:

    span.cat-links, span.cat-links a {
    	color: #492d00;
    	background-color: #e2dbcd;
    	margin-right: 5px;
    	padding: 3px 2px 1px 7px;

    from 'margin-right:5px;' and the second value in 'padding: 3px 2px 1px 7px;'

    set the 5px to 0px and 2px to 0px to remove all the space.

  5. aptdesignonline
    Posted 5 years ago #

    Alchymyth, you were totally right (much to my embarrassment). I needed to split out those two spans and style them differently. Thanks for your help!

Topic Closed

This topic has been closed to new replies.

About this Topic