Search code examples
phphtmlwordpressadvanced-custom-fields

<p> is not in the result inside a PHP condition


what is the wrong in this code that makes the removed from the result

<?php if(the_field('price',$postID)) : ?>  
          <p class="price"> <?php the_field('price',$postID) ; ?></p> 
          <?php endif; ?> 

The result show only the price without the p element

enter image description here


Solution

  • Just change

    the_field('price',$postID)
    

    By

    get_field('price',$postID)
    

    And Enjoy!