You should pretty much never need to use $wpdb
to grab data. There are helper functions built into WordPress that will do what you need.
In this case, use get_post_meta()
.
Having used https://www.unserialize.com/ to unserialize your data, it looks like the item list in your question is in $meta['toys_item']['toys_item_ranger']
. I’ll use that in my code snippet to make a list like the one you’re looking for.
$meta = get_post_meta( $post_id, 'fat-mb-boat-toys', true );
if (
! empty( $meta )
&& ! empty( $meta['toys_item'] )
&& ! empty( $meta['toys_item']['toys_item_ranger'] )
) {
foreach ( $meta['toys_item']['toys_item_ranger'] as $toy ) {
echo $toy . '<br />';
}
}
Related Posts:
- How to get all term meta for a taxonomy – getting term_meta for taxonomy
- Short of raw SQL, can I query for multiple attachment metadata that have a given array key?
- Triple meta_key on custom SELECT query
- Get updated post meta on save_post action?
- MySQL Query To Select Post By Postmeta
- Set Condition echo function get_post_meta
- Get a row from a separate table by matching a posts meta_key to a tables ID column
- Compare string with post id in wpdb and do stuff when match is found
- Read post meta values, only if posts are public
- How to test the outcome of a wpdb query?
- wpdb->get_var – count author posts, meta value
- How to query and update one colum in postmeta table?
- Display current ranking of post as a number in post title
- Get data from custom table and update relative post_meta based on meta_key
- Get table parameter and save in meta value
- Exclude category from DB query
- Fetching array of postmeta with $wpdb and in_array conditional
- Which query method to use? (edit- wpdb syntax problems)
- Cache metadata for set of posts
- How to get all the related ids without array?
- How do I retrieve the slug of the current page?
- How to extract data from a post meta serialized array?
- How to save an array with one metakey in postmeta?
- WordPress is stripping escape backslashes from JSON strings in post_meta
- Lack of composite indexes for meta tables
- So much data in postmeta
- Content hooks vs User hooks
- Why time functions show invalid time zone when using ‘c’ time format?
- WPDB Multiple site’s posts and get featured images
- Save both current and new version of post meta
- WP REST API “rest_no_route” when trying to update meta
- get_post_meta – get a single value
- What action hook updates post meta?
- get_post_meta / update_post_meta array
- How do I access post meta data when publishing a new post in Gutenberg?
- update_post_meta not adding anything.(Nor add_post_meta)
- Identifying Importer Posts
- How metadata API works?
- How to sanitize post meta field value?
- Post IDs missing on delete_postmeta action hook
- How trigger to save post when updating post meta
- Create a Metabox that behaves Like a Taxonomy Box
- Views count with time limit per IP
- order by multiple meta_keys?
- Multiple postmeta with same name for one post in wp_postmeta table
- Custom meta field don’t give me numerical value
- echo image caption
- get_*_meta doesn’t always return an array
- Generate multiple goo.gl shortlinks for qtranslate bilingual blog
- What is faster: custom taxonomy or serialized post-meta for db retrieval? (over 60,000 posts)
- How can I convert postmeta from unserialized to serialized?
- How to hide meta block(s) in certain post format
- add_post_meta adds meta to one more different post
- Custom query, multiple custom keys
- Trying to get property of non-object error using get_post_meta()
- How can I change the tag contents of individual WordPress posts?
- get_post_meta producing white screen of death
- update_post_meta not working in plugin
- how to get a list of meta data fields assocaited with a custom post type
- How to insert multiple postmeta values with one query?
- Look up all posts by status or meta value – performance difference
- Can A Post Meta Field Store multiple values that are not in an array?
- esc_attr on get_post_meta [closed]
- Sort custom posts in archive by multiple values: date AND meta key
- How is the author’s name given a different color?
- How does WordPress treats attachments metadata in post content?
- URL to Post Meta [closed]
- How to delete duplicate records in wp_postmeta database table?
- Retrieving post meta array (attachment)
- Why is variable that get_post_meta stored in empty?
- Stop `update_post_meta` from working each time page refreshes?
- get_post_meta in one post only
- Search post overlapping dates – meta_query with meta_key
- I want to Add Feedburner Right After Meta Details
- if get_post_meta function returns empty – Do Not Display HTML
- Custom column on CPT not showing correct value when meta data not set
- How to access post meta on the first time a post is published
- I Can’t get the post_tag name from term_id using wp_set_object_terms
- URL from get_post_meta() is broken my URL
- How to update/add child posts meta whenever the parent post meta is updated?
- How to query post with meta?
- why is my postmeta table is so heavy
- update_post_meta() throws Uncaught error: Cannot create duplicate attribute
- Using a comma instead of a pipe to separate metadata
- Export media library with metadata and import into new blog
- show user based on user_meta
- Meta keys won’t add using wp_insert_post
- How Can I extract Image urls from post meta
- Twenty Twelve entry meta data – change and move
- How can I prevent the post_modified column in wp_posts from being updated?
- Sorting meta box values by start- and enddate and all dates in between
- Use an id on a button to update_post_meta in post
- get_post_meta image width for lazy load
- Write query according to post_meta
- Custom Fields help
- Why values dont shows in custom post column?
- WP-API : post_meta not updated… but have another entry
- Parse error thrown by get_post_meta [closed]
- Remove action of an external plugin after checking if custom post meta is set
- get_post_meta() returns nothing in save_post, publish_post, wp_after_insert_post