WordPress extra spaces breaks layout

I am creating and developing a custom WordPress theme and I am struggling with one issue, which is making me crazy and I can’t find any fix and can’t figure out, what I am doing wrong…

There is some extra spaces added in output which breaks the layout and creates empty space

Read More

here is my source code (index.php):

<div class="c6">
    <h4>news</h4>
    <?php query_posts('showposts=3'); ?>
    <?php if (have_posts()) : while(have_posts()) : the_post(); ?>
        <?php get_template_part('content', get_post_format()); ?>
    <?php endwhile; else : ?>

        <p><?php _e('No posts were found!', 'unqvsn-framework'); ?></p>

    <?php endif ?>

    <p class="articles-nav-prev"><?php next_posts_link(__('&raquo; Older Posts', 'unqvsn-framework')); ?></p>

</div>

and here is also code for the left column sidebar, where it is happening too (as well as for each sidebar I create):

<h4>Line up</h4>
<div class="sidebar"><?php get_sidebar('lineup-sidebar'); ?></div>

and here is the output with inspected code in the browser (Chrome, the same happens in Firefox):

Screenshot

Any ideas?

Thanks

Related posts

Leave a Reply

2 comments

  1. One thing you can try is adding html comments in between your php tags to prevent the extra whitespace

    <h4>news</h4><!-- no whitespace
        --><?php query_posts('showposts=3'); ?><!-- no whitespace
        etc...
        --><p class="articles-nav-prev">