Need help? Check out our Support site, then

While Loop extra spaces between results

  1. I have a while loop that is giving me some formatting issues when it renders in browser. I am trying to list some posts (comma separated) in a paragraph tag.

    $postCount = 0;<br /> echo '<p>';<br /> while ( $platforms->have_posts() ) : $platforms->the_post();?><br /> <a>" title="<?php the_title();?>"><?php trim(the_title());?></a><br /> <?php<br /> ++$postCount;<br /> if ($postCount < $platforms->found_posts) {<br /> echo ", ";<br /> }<br /> endwhile;<br /> echo '</p>';

    However when I look at the HTML source, there’s all this extra white space that is adding an extra space in the browser view.
    <p> <a href="mysite" title="TitleA">TitleA</a><br /> , <a href="mysite" title="TitleB">TitleB</a><br /> , <a href="mysite" title="TitleC">TitleC</a><br /> </p>

    So instead of my format looking like this: TitleA, TitleB, TitleC

    There is extra space before the comma.
    TitleA , TitleB , TitleC

    Is there something in wordpress php that is causing each Title link to go to a separate line? I would expect the source to look like this
    <p><a href="mysite" title="TitleA">TitleA</a>, <a href="mysite" title="TitleB">TitleB</a>, <a href="mysite" title="TitleC">TitleC</a></p>

  2. You did not specify a blog address or reason for posting when you created this topic.

    This support forum is for blogs hosted at If your question is about a self-hosted WordPress blog then you'll find help at the forums.

    If you don't understand the difference between and, you may find this information helpful.

    If you forgot to include a link to your blog, you can reply and include it below. It'll help people to answer your question.

    This is an automated message.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.