• Resolved Edna Houston

    (@ediehouston)


    I am using a PHP widget to check for the existence of a particular custom field and display it if it exists. I’ll call the field “information”. I do not use a widget title in this case because most of the time the custom field doesn’t exist and I didn’t want an empty title box in my sidebar. My code is shown below and it works fine.

    <? php $values = get_post_custom_values(“information”);
    if ( !empty($values) ) {
    echo ‘<h3 class=”widgettitle”>Information:</h3> ‘ . $values[0]. ‘ ‘;
    }
    ?>

    The problem is if there is no “information” custom field to display,
    I get an empty box. Not a huge problem, just esthetically displeasing.

    I am wondering is if there might be a way, say in functions, that I could keep the entire php widget from showing up if it has no value? Ideas?

Viewing 1 replies (of 1 total)
  • Thread Starter Edna Houston

    (@ediehouston)

    Never mind, guys. The plugin “Enhanced Text Widget” solves the problem via the check boxes in the widget itself. If no results are returned by the query..you don’t see anything. Great and thank you.

Viewing 1 replies (of 1 total)
  • The topic ‘Hide entire widget if no results returned’ is closed to new replies.