WordPress企业主题定制/开发/优化

wordpress 函数 get_post_meta() 详解

首页 » WORDPRESS主题技术 » wordpress 函数 get_post_meta() 详解

wordpress 函数 get_post_meta() 详解

官方文档: http://codex.wordpress.org/Function_Reference/get_post_meta

使用方法:

<?php $meta_values = get_post_meta($post_id, $key, $single); ?>

说明:

$post_id
(整数) (必须的)包含此meta文章的ID

$key
(字符串) (必须的) 此meta的名称

$single
(布尔型) (可选) 如果设为true, 则返回单个的meta的值。如果设为false, 则返回一个数组字符串型。

示例:
<?php $key_1_values = get_post_meta(76, 'key_1'); ?>
<?php $key_1_value = get_post_meta(76, 'key_1', true); ?>

相关项目

  • WordPress外贸企业主题

  • 最近更新

  • 热门标签