Support » Fixing WordPress » action if custom field is not empty

  • I have a php function to call the value of a custom field so that I can display it on the page. It looks like:


    <?php if ( $post->post_name == $show_chapter) {
    foreach(get_post_custom_values('Teaser') as $tease) {
    $nvteaser = $tease;
    }
    ?>

    Worked fine in 2.0.2 as-is, but in 2.0.4 I’m getting an error message if there’s no content in the “Teaser” custom field.

    Therefore I’d like to rewrite this function so that if the Teaser field is empty (something like, if empty($CUSTOM_FIELD(['Teaser']) , perhaps?), the function will not run.

    I am completely out of my programming depth! So if anyone has advice I’d be most appreciative.

    Thanks, Sara

  • The topic ‘action if custom field is not empty’ is closed to new replies.