custom fields erros when no value available (2 posts)

  1. rebekah ford
    Posted 6 years ago #

    I've set up posts to have several relevant custom fields.
    each post may use a few or all of the fields that i've set up. however when a post has no need for some of the fields and i have not used them, i can see an error message appear for that particular line on the page.

    i have added a conditional statement for each but the error message seems to still prevail.

    the code looks something like this

    									if (empty ($custom_fields) )
    											echo "";
    											$custom_fields = get_post_custom();
    											$Track1 = $custom_fields['Track13'];
    											foreach ( $Track13 as $key => $value )
    											echo  $value . "<br />";

    and the error i get is like this relating to the foreach

    Warning: Invalid argument supplied for foreach() in /content/BusinessHostPlus/b/u/burntprogress.com/web/promo/wp-content/themes/burntpromo/single.php on line 260

    any idea what i'm doing wrong?

  2. taffeljohan
    Posted 6 years ago #

    Um, typo?

    You assign a value to $Track1 and then you try to use $Track13 in your foreach statement.

Topic Closed

This topic has been closed to new replies.

About this Topic