[wp-trac] [WordPress Trac] #17087: get_post_meta returns empty array when requesting non-exsistent post meta
WordPress Trac
wp-trac at lists.automattic.com
Sat Apr 9 05:33:27 UTC 2011
#17087: get_post_meta returns empty array when requesting non-exsistent post meta
-------------------------------+------------------------------
Reporter: thomasvonhassel | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.1
Severity: major | Resolution:
Keywords: reporter-feedback |
-------------------------------+------------------------------
Changes (by dd32):
* keywords: => reporter-feedback
Comment:
Could you post some code which shows the problem? I'd suggest disabling
all plugins and any caching related items as well.
The following code works for me:
{{{
<?php
update_post_meta(7, 'testkey', array('Value1', 'Value2'));
$id = 1;
var_Dump(
get_post_meta(7, 'testkey', true),
get_post_meta(7, 'testkey', false),
get_post_meta($id, 'foobar', true),
get_post_meta($id, 'foobar', false),
get_post_meta($id, 'testkey', true),
get_post_meta($id, 'testkey', false)
);
?>
Output:
array
0 => string 'Value1' (length=6)
1 => string 'Value2' (length=6)
array
0 =>
array
0 => string 'Value1' (length=6)
1 => string 'Value2' (length=6)
string '' (length=0)
array
empty
string '' (length=0)
array
empty
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17087#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list