I am trying to bring through content based on a unique GUID. The database is stored in a serialized array and this cannot be changed.
An example record would be:
a:1:{i:0;s:8:"16YL3332";}
And I currently use this in WP to serialize the string and run it in get_posts
function using the following args
$guid serialize(strval($_GET['guid'])); // var dump = string(15) "s:8:"16YL3332";"
$args = array(
"post_type" => "custom-post-type",
"post_status" => "publish",
"posts_per_page" => 1,
"meta_query" => array(
"key" => "_fixtures",
"value" => array($guid),
"compare" => "LIKE"
)
);
I am having no success in bring the appropriate data back. WP defaults to bring back the most recent content published in the post type.
Why are you casting the $guid variable to an array? I'm not sure that's needed. If you just pass it as 'value' => $guid
, does that work?
Also, see the following QA for some more information that may help you: