[wp-trac] [WordPress Trac] #42687: get_post_meta() is returning arrays even when the $single value is true
WordPress Trac
noreply at wordpress.org
Fri Nov 24 09:09:16 UTC 2017
#42687: get_post_meta() is returning arrays even when the $single value is true
-------------------------------+------------------------------
Reporter: titodevera | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 4.9
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses:
-------------------------------+------------------------------
Changes (by dd32):
* keywords: => reporter-feedback
Comment:
Hey @titodevera and welcome to Trac!
Can you check your database directly to see if the metadata for the post
is what you expect?
Testing it, it seems to be working as expected for me:
{{{
var_dump( get_post_meta( 1789, 'name', true ) );
var_dump( get_post_meta( 1789, 'name', false ) );
results in:
string 'one' (length=3)
array (size=2)
0 => string 'one' (length=3)
1 => string 'two' (length=3)
}}}
Note, that if you have stored an array in the meta value, it'll return
that array as the "single" key - WordPress supports multiple meta_values
for any given meta_key.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42687#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list