WordPress.org

Ready to get started?Download WordPress

Forums

action if custom field is not empty (1 post)

  1. scormeny
    Member
    Posted 7 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic