Your data is being serialize properly. Your code saves an array of integers. Integers are not strings and so a string length is not saved. Run the following code and it should illustrate the point:
$str="a:4:{i:0;s:4:"7613";i:1;s:4:"7615";i:2;s:4:"7616";i:3;s:4:"7618";}";
$str = maybe_unserialize($str);
var_dump($str);
echo '<br/>';
var_dump(maybe_serialize($str));
echo '<br/>';
$str = array(
1234,4567,8910,1112
);
var_dump(maybe_serialize($str));
echo '<br/>';
$str = array(
'1234','4567','8910','1112'
);
var_dump(maybe_serialize($str));
To get the results you want, save strings and not integers:
// Fill the array with attachment ID's
foreach($attachments as $attachment) {
$atts[] = "$attachment->ID";
}
Related Posts:
- update_post_meta from data in multidimensional array created from a form
- update_post_meta() with a modified array?
- 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
- Random element in get_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?
- How to extract data from a post meta serialized array?
- Nice way to print_r arrays
- Why does get_users suddenly return duplicates?
- When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
- How can merge two arrays values in one array and save in database
- WordPress: How to use post_class() in an echo
- Is it possible to store arrays in a custom field?
- How do I pass an array as an argument to a WP-CLI command?
- How to update single value in multi dimensional Post Meta?
- Updating wp_options with an array on save_post results in duplicated entries
- Passing a variable into Contact Form 7 [closed]
- Comma seperated list of ID’s as an array?
- How to store post meta in an array?
- WP Meta Query for some meta (array) values
- post__in works but also prints the word Array
- Make Selected Mutiselect Items “selected”
- Compare two meta key values against each other inside the get_posts array?
- settings api store multiple 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
- How to save array of datas in option page by setting api?
- Sort a custom post type array numerically
- How to add day number and initial to my post graph?
- How to validate register settings array
- How to check an array of $curauth fields?
- Problem with wp_update_post
- Replace text inside a huge multidimensional array
- How to use IN array properly in WordPress?
- Get specific custom field keys from a post and put into an array
- My theme saves their custom post type’s metadata as a serialized array, how to access the keys?
- WordPress Plugin Dev: Using array for WP options
- Only a part of array is stored in transient – what could be causing this?
- Return array keys and values
- 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
- Echoing a variable inside a function
- Stuck with a Custom Field Check box Array
- Unset field from an array not working as expected
- 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?
- Combine get_page_by_title to exclude pages from wp_list_pages
- Plugin settings page checkbox not saving – one options array with sub array
- Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
- Selecting and outputting results from DB with an array
- Struggling with array and foreach loop
- Customizer Settings in Arrays
- WordPress i18n in Array throws Error
- How to decipher the following array
- Save meta box values as an array to wp_postmeta
- 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
- Output meta into arrays
- Get array of metakey in all posts
- 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
- Array in meta key?
- Saving array keep adding length of array
- Obtaining values from objects
- How to get a page array and category array going at the same time?
- search serialised meta_value for date value?
- Remove “%” from strings in serialized arrays in wp_postmeta
- get_the_terms, whether I should use string or array as the second parameter?
- How to use two meta_compare in an array?
- Obtaining array item from WordPress revisions output
- 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
- Do not replicate items if they exists in a foreach loop
- WP Page Options Array
- Order a WP_Query by meta value where the value is an array
- Array is not working in Filter?
- How to put an array in wp user query
- Get the values from an array string to work with post__in
- Update value of a associative array with update_post_meta
- return paginate_comments_links() as array