0

I am on the last step in a tutorial that I followed here , called "Using the data".

I tried using//

$album_repeatable = unserialize($post_meta_data['album_repeatable'][0]);  
        echo '[ul class="album_repeatable"]';  
        foreach ($album_repeatable as $string) {  
            echo '[li]'.$string.'[/li]';  
        }  
        echo '[/ul]';

But I get the Warning as stated in Question Title//

"Warning: Invalid argument supplied for foreach() "

What exactly is the issue here?

4
  • $album_repeatable is not an array.
    – fuxia
    Jul 11, 2013 at 6:52
  • @toscho I renamed "custom" to "album"...
    – keilowe
    Jul 11, 2013 at 7:00
  • Do not unserialize the post meta field. Then try var_export( $album_repeatable ); to inspect the value.
    – fuxia
    Jul 11, 2013 at 7:01
  • @toscho Thank you for the suggestion, but I am new to PHP etc so I have no idea how to do this...Appreciate your help!
    – keilowe
    Jul 11, 2013 at 7:04

1 Answer 1

0

Used normal method to get field data instead of "unserialize"

Switched this line:

$album_repeatable = unserialize($post_meta_data['album_repeatable'][0]);  

to this line:

$album_repeatable = get_post_meta($post->ID, 'album_repeatable', true);  

Now my repeatable field Data is being displayed.

Thanks @toscho for pointing it out...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.