我试图通过基于唯一GUID的内容。数据库存储在序列化数组中,不能更改。
一个示例记录是:
a:1:{i:0;s:8:"16YL3332";}
我目前在WP中使用这个来序列化字符串并使用以下args
get_posts
函数中运行它 $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"
)
);
我没有成功地把适当的数据带回来。WP默认在post类型中返回最新发布的内容。
为什么要将$guid变量转换为数组?我不确定是否需要。如果你把它作为'value' => $guid
通过,这样行吗?
另外,请参阅以下QA以获取可能对您有所帮助的更多信息:
https://wordpress.stackexchange.com/questions/115833/how-do-i-search-an-array-stored-in-a-custom-field-using-wp-query