我正在使用get\\u post()调用单个Wordpress帖子,并使用其帖子ID。我已成功获取帖子的内容/标题,但也希望获取自定义字段。
下面的代码是如何在标准wp\\U查询中声明自定义字段的:
$customField = (get_post_meta($post->ID, "_mcf_customField", true));
我的get\\U邮编如下: $my_id = 401491;
$post_id = get_post($my_id);
$customField = get_post_meta($post_id, "_mcf_customField", true); // I do not think this is correct
$content = $post_id ->post_content;
echo $content;
echo $customField; // No output
我相信上面的customField变量声明不正确,但在Codex中似乎找不到任何可以说明问题的东西。有没有人有过在get\\u post中使用自定义字段的经验?