Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Getting “Invalid argument supplied for foreach()” Warning…

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #46309
    asiek
    Participant

    I am on the last step in a tutorial that I followed [here](http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-4-using-the-data/http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-4-using-the-data/”) , called “Using the data”.

    I tried using//

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

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

    “_Warning: Invalid argument supplied for foreach()_ “

    What exactly is the issue here, in terms I could understand? lol
    Please help me fix this?…

    #142237
    asiek
    Participant

    **SOLUTION**//
    Used normal method to get field data instead of “_unserialize_”

    Switched this line:

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

    to this line:

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

    Now my repeatable field Data is being displayed.

    #142358
    asiek
    Participant

    @traq I appreciate you trying to explain, just wish I understood it lol!
    But yeah…thank you :)

    #142724
    asiek
    Participant

    @traq I was just following the tutorial, that’s all. hehe :)

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.