GeekerCode更好的WordPress主题,值得信任的WordPress主题开发商

极美的主题、极致的插件

WordPress获取自定义字段值函数:get_post_custom()

摘要:【描述】同get_post_meta()一样,用于返回文章的自定义字段值得一个函数,只不过get_post_custom()函数使用起来更简单,如果在循环中使用你甚至不需要设置任何参数。【用法】<?php get_post_c

【描述】

同get_post_meta()一样,用于返回文章的自定义字段值得一个函数,只不过get_post_custom()函数使用起来更简单,如果在循环中使用你甚至不需要设置任何参数。

【用法】

<?php get_post_custom($post_id); ?>

【参数】

$post_id

(整数)(可选)将要检索的自定义字段的文章编号。

默认值:Current post

【示例】

if (have_posts()) :
 while (have_posts()) : the_post(); 
    var_dump(get_post_custom());
 endwhile; 
endif;

输出的结果如下:(如果如下字段有设置的话)

array(4) {
["_edit_last"]=>
array(1) {
[0]=>
string(1) “1″
}
["_edit_lock"]=>
array(1) {
[0]=>
string(12) “1342451729:1″
}
["_thumbnail_id"]=>
array(1) {
[0]=>
string(3) “228″
}
["xzmeta"]=>
array(2) {
[0]=>
string(3) “xz1″
[1]=>
string(3) “xz2″
}
}

建站!你有充足的理由选择我们

世界上超过30%的网站是由WordPress搭建,而我们是国内最靠谱的WordPress主题开发商
QQ咨询在线咨询问答互助微信号geekercode微信公众号云服务器