WordPress.org

Ready to get started?Download WordPress

Forums

A Conditional for Empty Content (2 posts)

  1. misterpatrick67
    Member
    Posted 3 years ago #

    Hi all,

    I am trying to figure something out. I am using Magic Fields to generate a series of tabbed content on pages. It is used outside of the loop. I am trying to find a way to hide the div if there is no content in Magic Fields. Right now, it shows the empty divs which are styled. Not sure of the best way to do this. Thanks!

    Here's the sample page code.

    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. David Calhoun
    Member
    Posted 3 years ago #

    I don't know exactly what you are trying to do since your code was removed by the moderator, but you should be able to assign your get() request to a variable and then check it it's not empty.

    <?php
      $my_value = get('my_magic_field');
      if ($my_value != '') {
        // do stuff
      }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic