Home Forums General Issues Remove whitespace


Remove whitespace

  • Hi,

    how can I do to remove whitespace (text nodes)?

    You can see here:
    Top of the page, below the post title there are 3 circles with different colors: these are obtained by checkboxes choices, transformed in circles via css.
    Between each circle you can see the issue when you inspect the code…

    Many thanks,

  • I forgot to show you the code I use to display the field:

    <?php $colore = get_field(‘colore’);
    if( $colore ): ?>
    <?php foreach( $colore as $colore ): ?>
    <span class=”color-<?php echo $colore; ?>”></span>
    <?php endforeach; ?>
    <?php endif; ?>

  • The white-space is created because of the way you’ve formatted your code.

    Every time you close php ?>' and then open it again on a new line<?php `, the page outputs that new line. All of those open/close php tags are unnecessary.

      $colore = get_field('colore');
      if( $colore ):
        foreach( $colore as $colore ):
          ?><span class="color-<?php echo $colore; ?>"></span><?php 
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Remove whitespace’ is closed to new replies.