As the content of the meta data is actually a string (according to your comment), your code won’t work. get_post_meta()
, respectively get_metadata()
will only deserialize the content if it’s actually serialized.
So, if you can’t change how the data is saved, ie make sure that an actual array
or already serialized content is passed to update_post_meta()
, then you have to manually explode your data into an array:
$theColor = get_post_meta($post->ID, 'colors', true);
$theColor = explode(',', $theColor);
Related Posts:
- update_post_meta from data in multidimensional array created from a form
- update_post_meta() with a modified array?
- How to get update_post_meta output to include string length
- Retrieving multiple values to the Post Meta (using an array)
- Update post meta does not serialize array
- How to use json_decode a post_meta value? [duplicate]
- Print specific values stored in a post meta array
- update_post_meta adding to array instead of replacing value
- Add Array record to Meta Post
- How i can extract data
- update_post_meta array issues
- Update Post Meta for Arrays — Remove/Replace Single Value from Multi Dimensional Array
- How do I retrieve a value from a multi – dimensional array using get_post_meta? [duplicate]
- How to match data in multidimensional array of post_meta_data?
- Nice way to print_r arrays
- How can merge two arrays values in one array and save in database
- WordPress: How to use post_class() in an echo
- How do I pass an array as an argument to a WP-CLI command?
- How to update single value in multi dimensional Post Meta?
- Comma seperated list of ID’s as an array?
- How to store post meta in an array?
- post__in works but also prints the word Array
- if is_singular array not working as expected
- How do I update a specific object in an array, in user meta?
- Get posts id in array by meta value and key
- Automatically adding meta data to posts or multiple query help
- Sort a custom post type array numerically
- How to add day number and initial to my post graph?
- How to validate register settings array
- Replace text inside a huge multidimensional array
- How to use IN array properly in WordPress?
- WordPress Plugin Dev: Using array for WP options
- Only a part of array is stored in transient – what could be causing this?
- How pass a 0 in $atts?
- get_*_meta doesn’t always return an array
- How to save data of an input field to an array
- Run a check for multiple meta key values
- Stuck with a Custom Field Check box Array
- Compare with WP Meta Query
- How to Translate a string of an array inside a class?
- How to pass conditional array to wp_localize_script
- Modify foreach loop for social sharing links?
- Selecting and outputting results from DB with an array
- Struggling with array and foreach loop
- How to decipher the following array
- How to display line breaked meta values in table?
- Post meta as array looks like string instead of array
- Organizing and grouping an array by year
- Time & Date on Post – Time Ago Custom Function
- array_filter warning – wp-includes/post.php line 3148
- Hide sidebar if post_type is in array
- Can A Post Meta Field Store multiple values that are not in an array?
- Create Array from custom post type to display a slider
- Obtaining values from objects
- search serialised meta_value for date value?
- Remove “%” from strings in serialized arrays in wp_postmeta
- Remove empty terms from array, sort alphabetically, update back to repeating field
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Matching slug terms from one array to those in array of WP_Term objects to output term names
- change order of images attached to post
- WP Page Options Array
- Update value of a associative array with update_post_meta
- return paginate_comments_links() as array
- Inserting a random number into an array [closed]
- update_user_meta duplicates entry
- Add formatting to Array
- Echo 2 values from one key in Array with get_post_custom
- How can I update this array built from post meta data?
- What format is this and how to get value “lal” and “pila” from it
- Trouble with serialized metadata
- Why are array_slice() and array_chunk() not working?
- Retrieve array items without page ID
- How do i fix this “call_user_func_array()” error
- How can I get the content of the current page in my loop while merging post-type
- wp_insert_post($post), add an array of values with update_post_meta
- How to output get_tags array list to select box
- How to avoid duplicate users when I am using get_users?
- How to add each letter, entity, special character from post title to array
- Remove item from post_meta array via AJAX
- Strange Behavior with update_option
- Show Tags of Custom Post Type outside of Loop
- “Undefined variable: array” Error In Displaying Post Tag
- wp_set_object_terms not accepting variable array
- How do I pull post from standard post format?
- Plugin Shortcode value in post
- The writing ( with foreach) of the keys of an array of objects to a new array produces fatal error
- Fetching array of postmeta with $wpdb and in_array conditional
- Use $wp_customize->add_control to create a selectable “Designed/Powered By” choices select w/ link in footer?
- Echo the key from a select-box in Array with get_option (Settings API)
- Updating wordpress user meta data array (unexpected multiple arrays)
- Accessing array elements (get_pages)
- Printing out JSON array returned [closed]
- How do i output images from URL’s added to the same custom field key
- Fatal error in my WP
- Build Array from Input Fields question
- SQL query add only posts with custom field to array
- Combine two foreach Arrays into one table row
- Populate Array with values from another arrray [closed]
- how to separate array with commas? [closed]
- Multipe array in meta_input