[wp-trac] [WordPress Trac] #42699: WP_Post $post object not properly returning values for meta keys
WordPress Trac
noreply at wordpress.org
Sun Nov 26 01:53:58 UTC 2017
#42699: WP_Post $post object not properly returning values for meta keys
--------------------------------+------------------------------
Reporter: saiu | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version: 4.9
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------------+------------------------------
Comment (by saiu):
I'm displaying a custom post type defined by the theme, so I cannot try
another theme.
I used `gettype()` on the `$post` variable and for the posts that are
producing an error, it is an array! On the two that this line works for
the `$post` variable is an object.
However, just 3 lines above the problematic one I am also using the
`$post->metakey` property to get a different meta key-value pair,
`$post->projectsiteid`, and that works just fine for every one. Even the
ones where `gettype($post)` returns `array`, the code
`$post->projectsiteid` works 3 lines up. Why would that work if `$post`
weren't an object for that iteration of the loop?
So...why, for the query of this custom post type, are 6 of the 8 returned
as an array and the other 2 returned as objects?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42699#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list