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

  1. aptharsia
    Posted 4 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?


  2. aptharsia
    Posted 4 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

  • Custom Fields Creator
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic