get posts meta query returning the latest post if no meta key foundPosted: - Source : stackoverflow
I have this pretty standard script that looks for a preview or a report (custom post types) which have data stored against them (serialized array) taking the form of a
The guid is present on my report and not present on my preview (this is intended as I want to catch the failure).
However, when I run the script for preview, the
get_posts returns one post which seems to be the latest post published.
$args = array( "post_type" => array($type), "posts_per_page" => 1, "post_status" => "publish", "orderby" => "date", "order" => "DESC", "meta_query" => array( "key" => "_fixtures", "value" => $fixguid, // IN THIS CASE IT SHOULD BE 12AB1324 "compare" => "=" ) ); $posts = get_posts($args); return $posts;
The report (which has the meta data
12AB1324) is returned successfully but the preview returns the latest story which happens to have a value of
I suppose my question is:
Why does get_posts meta query return
a) the latest post and
b) a post with a guid that doesn't
= the given