您的当前位置:首页 > 知识博客 > wordpress建站

WordPress返回文章元数据值函数:get_post_custom_values

时间:2024-03-09

WordPress函数get_post_custom_values返回文章所有元数据的值。

get_post_custom_values( string $key = '', int $post_id )

函数参数

$key

字符串

自定义字段的键

$post_id

整数

文章的ID

函数返回值

Array
(
    [0] => 123
)

函数使用示例

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

扩展阅读

get_post_custom_values()函数位于:wp-includes/post.php

相关函数:

  • get_post_custom()

  • get_post_custom_keys()

  • the_meta()

  • get_post_meta()


欢迎咨询/Welcome to inquire
tel/vx:18842938855
qq:1685522781
email:1685522781@qq.com

Copyright © 2019-2024 21329.com


Whatsapp
Powered by RRZCMS