Custom Fields ( foreach giving errors when emty )
-
Hi there,
I have a question, I am building a custom post type for my portfolio area on my website. This is all working out very nice, but now I am running in to the following problem. I am using Custom Fields to Echo portfolio specification in a [ul] [li], to do this I copy’d and edited to following code form the wordpres codex site :
<ul> <?php $custom_fields = get_post_custom(); $specificaties = $custom_fields['specificaties']; foreach ( $specificaties as $key => $value ) { print " <li> " . $value . "</li>"; } ?> </ul>
I edited it so it would not show the Value ID, but now the problem is, when a item doesnt go any value it gives the following error
Warning: Invalid argument supplied for foreach()
I am not that great with PHP just yet, I am starting to learn it bit by bit. I would say that I need to add something like a ELSE ore something but everything I try results in errors.
Hope somebody can help me ??
Kind Regards,
Wilco
- The topic ‘Custom Fields ( foreach giving errors when emty )’ is closed to new replies.