WordPress获取指定文章所有自定义字段函数get_post_custom()
在WordPress主题或插件开发过程中,我们可能会需要获取指定文章或页面的所有自定义字段,这时我们直接使用WordPress自带函数get_post_custom()就可以了。
<?php get_post_custom($post_id); ?>
函数参数详解
$post_id
(integer) (optional) 要获取所有自定义字段的日志 ID。
Default: 当前日志
返回值
(array)
返回指定日志的所有自定义字段的关联数组。