Support

Account

Home Forums Front-end Issues Empty Field Not Returning As Empty

Helping

Empty Field Not Returning As Empty

  • I have some code like:

    <?php 
    if(get_field('review'))
    $videoReview = get_field('review', false, false);
    $String  = explode("?v=", $videoReview)[1];
    { echo '<div class="youtube-player" data-id="' . $String . '"></div>'; } ?>

    And no matter what the div appears on the page. I know that in many circumstances the review field is empty in the db but it still comes through as if it was populated. The if statement works in most cases but here it seems to be ignored.

    Any ideas?

  • Can you not create a variable for review and then just check if it’s set?

    <?php 
    
    $review= get_field('review');
    
    if (isset ($review)) {
    
    echo '<div class="youtube-player" data-id="' . $String . '"></div>'; 
    
    } ?> 
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.