Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Matt Campbell
Matt Campbell
9,767 Points

I'm stuck - extrapolating values from a get_post_meta array

I've been working all day on making a meta box that has tabs and the option to add a new meta box. It's for a menu that's at events. Food menu, not nav!!!

It's meant to work like this. Backend, you have a meta box with 3 or 4 tabs labelled menu. Then a row or two with menu item label and a text box to enter the menu item. Got to have a button to add a new row of menu item label and text box and a button to remove row. All of this is in place and working well. Data is saved blah blah blah.

My issue now is getting this data that's saved in a $menus array, into the front end. So far, I've got to this stage.

Array ( [1] => Array ( [title] => Ham ) [2] => Array ( [title] => Fish ) [3] => Array ( [title] => Beef ) [4] => Array ( [title] => Turkey ) ) 1

Not very good! I can't work out how to extract the Ham, Fish, Beef and Turkey values into a manner that I can then put them in a list. Crazy menu I know!

Any help from Randy Hoyt or Zac Gordon or anyone else in the know, would be massively appreciated!

My code to get this data to where it is now is:

echo print_r(get_post_meta($post->ID,'menus',true));

Hoping for a solution.

Thanks all.

1 Answer

Matt Campbell
Matt Campbell
9,767 Points

I got it in the end. YEY!!! Amazing what coming back to something after a few hours can do