WordPress.org

Ready to get started?Download WordPress

Forums

Custom Fields Creator
[resolved] Hide if empty (2 posts)

  1. aptharsia
    Member
    Posted 2 years ago #

    <?php $Status = get_post_meta($post->ID, "Status", true); ?>
    <?php foreach($Status as $Status) { echo $Status ['status']; } ?>

    That is the code I'm using. It works fine except for posts that do not have the newly created field added, I get this error on the posts:
    Warning: Invalid argument supplied for foreach() in /***/archive.php on line 32

    What am I doing wrong and how would I fix it?

    http://wordpress.org/extend/plugins/custom-fields-creator/

  2. aptharsia
    Member
    Posted 2 years ago #

    I received an email of a follow up but don't see it here. I used this:

    `<?php $Status = get_post_meta($post->ID, "Status", true);
    if( !empty($Status) )
    foreach($Status as $Status) {echo $Status ['status'];} ?>'

    So thank you!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic