• Hello all!

    I finally managed to get my custom fields into my ppsts just the way I wanted. HOWEVER, I’ve discovered, if I use ,say, only 2 of the three set out below, the one missing will show up as an error:

    Warning: Invalid argument supplied for foreach() in /home/.../...

    How can I make the Custom fields work and have the non-showing ones not wreak havoc?

    <span class="meta-data">
    <?php
    
      $mykey_values = get_post_custom_values('Client');
      foreach ( $mykey_values as $key => $value ) {
        echo "<strong>Client:</strong> $value<br />";}
    
    ?>
    <?php
    
      $mykey_values = get_post_custom_values('Brief');
      foreach ( $mykey_values as $key => $value ) {
        echo "<strong>Brief:</strong> $value<br />";
      }
    
    ?>
    <?php
    
      $mykey_values = get_post_custom_values('Media');
      foreach ( $mykey_values as $key => $value ) {
        echo "<strong>Media:</strong> $value<br />";}
    
    ?></span>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom field – some giving errors if not used.’ is closed to new replies.