• rebekah-ford

    (@rebekah-ford)


    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

    <?php
    									if (empty ($custom_fields) )
    										{
    											echo "";
    										}
    									else
    										{
    											$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?

Viewing 1 replies (of 1 total)
  • taffeljohan

    (@taffeljohan)

    Um, typo?

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

Viewing 1 replies (of 1 total)
  • The topic ‘custom fields erros when no value available’ is closed to new replies.