数字化技能提升教程,数字化时代生存宝典

数字化百科 / 产品文档 / WordPress:Function Reference/get post custom values

WordPress:Function Reference/get post custom values

查看全部产品文档命名空间:WordPress

描述

返回一个数组,包含某篇文章($post_id)某关键字($key)自定义fields的所有参数值。如果不存在这样的关键字,或者没有输入任何内容,不返回任何内容。也看看get_post_custom()get_post_custom_keys()

用法

%%% <?php get_post_custom_values($key, $post_id); ?> %%%

例子

默认用法

下面的例子将一个变数($mykey_values)设置为一个数组,包含关键字为my_key的当前文章的自定义fields的参数值。

<?php

  $mykey_values = get_post_custom_values('my_key');
  foreach ( $mykey_values as $key => $value ) {
    echo $key . " => " . $value . "<br />"; 
  }

?>

0 => First value with "my_key" as its key
1 => Second value with "my_key" as its key
2 => Third value with "my_key" as its key
etc...

参数

相关的

add_post_meta(), delete_post_meta(), get_post_meta(), update_post_meta(), get_post_custom(), get_post_custom_keys()