对get_post_custom()在使用WordPress的发展功能
像get_post_meta(),返回文章自定义字段值的功能,但get_post_custom()函数使用的是简单的。如果你在循环中使用它们,你甚至不需要设置任何参数。事实上,这get_post_custom基本实现()函数是类似的get_post_meta()。
get_post_custom()使用
get_post_custom($,);
只接受一个参数
美元,文章编号;
榜样示范
如果(have_posts()):
而(have_posts()):the_post();
var_dump(get_post_custom());
endwhile;
Endif;
输出的结果如下:(如果设置了以下字段)
数组(4){
{ _edit_last } = >
数组(1){
{ 0 } >
字符串(1)1
}
{ _edit_lock } = >
数组(1){
{ 0 } >
(12)1342451729:1字符串
}
{ _thumbnail_id } = >
数组(1){
{ 0 } >
字符串(3)228
}
{ xzmeta } = >
数组(2){
{ 0 } >
(3)高效的字符串
{ 1 } >
字符串(3)XZ2
}
}
get_post_custom_values和get_post_custom_keys
因为自定义字段分为关键(钥匙)和自定义字段的值(值),还有当我们需要单独访问这两个值的时候,那么WordPress是get_post_custom_values和get_post_custom_keys两函数的推导,至于意思,我真的没有发现多少意义,除了当批删除自定义字段使用到一定程度,除非,我真的不觉得什么地方都可以用,也许是在一个巨大的CMS主题会对船员的重要意义。
这get_post_custom和get_post_meta功能,在私下认为,无论如何,自定义字段的相关功能也不多,所以很容易完成,只需把自定义字段相关的功能写的,当然不包括现代的实数编码的一些基本功能。
get_post_custom_values是用来获取指定的自定义字段的值与当前文章中的数组的形式返回。
而(have_posts()):the_post();
var_dump(get_post_custom_values('xzmeta '));
endwhile;
Endif;
它将返回以下结果
(如果设置了自定义字段)
数组(2){
{ 0 } >
(3)高效的字符串
{ 1 } >
字符串(3)XZ2
}
get_post_custom_keys用于获取所有当前文章的自定义域的关键值。
如果(have_posts()):
而(have_posts()):the_post();
var_dump(get_post_custom_keys());
endwhile;
Endif;
一般得到以下结果:
(如果设置了自定义字段)
数组(4){
{ 0 } >
(10)_edit_last字符串
{ 1 } >
(10)_edit_lock字符串
{ 2 } >
(13)_thumbnail_id字符串
{ 3 } >
(6)xzmeta字符串
}