While Loop extra spaces between results

  • Author
  • #1072756

    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;
    echo '<p>';
    while ( $platforms->have_posts() ) : $platforms->the_post();?>
    " title="<?php the_title();?>"><?php trim(the_title());?>
    if ($postCount < $platforms->found_posts) {
    echo ", ";
    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> TitleA
    , TitleB
    , TitleC

    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>TitleA, TitleB, TitleC</p>



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

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

    If you don’t understand the difference between WordPress.com and WordPress.org, 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.

The topic ‘While Loop extra spaces between results’ is closed to new replies.