echo get_post_meta( get_the_ID(), 'custom_field_key', true );<br> 5.保存更改并刷新页面。 假设你的文章有一个自定义字段,键名为phone_number,值为123-456-7890,你可以将代码替换为: echo get_post_meta( get_the_ID(), 'phone_number', true );<br> 在前端页面上,用户会看到以下内容: 123...
WordPress函数:get_post_meta 获取文章自定义属性 在WordPress 主题/插件开发中,get_post_meta 使用的频率非常高。 常用的使用方式如下: $key_1_value=get_post_meta(get_the_ID(),'key_1',true);// Check if the custom field has a value.if( !empty($key_1_value) ) {echo$key_1_value; } 函...
php$meta= get_post_meta( get_the_ID() ); ?> 获取单个 key 的 meta: 1 <?php$key_1_values= get_post_meta(76,'key_1'); ?> 在主循环中获取指定 key 的第一个值 1 2 3 4 5 6 7 <?php $key_1_value= get_post_meta($post->ID,'key_1',true); // checkifthe custom field h...
$post_id = yit_post_id();// get color and background from postmeta$color =yit_get_post_meta($post_id,'_bg_color',true); $image =yit_get_post_meta($post_id,'_bg_image',true);// get the color and background from theme options, if above are empty$background = yit_get_option...
<?php$meta= get_post_meta( get_the_ID() ); ?> <?php$key_1_value= get_post_meta( get_the_ID(),'key_1'); ?> <?php$key_1_value= get_post_meta( get_the_ID(),'key_1', true ); ?> The first line of code is how we get the meta for all the keys, which is getting...
(int) $post_id Post ID. Required: 是 (string) $key Optional. The meta key to retrieve. By default, returns data for all keys. Default empty. Required: 否 Default: (empty) (bool) $single Optional. Whether to return a single value. This parameter has no effect if `$key` is ...
get_post_meta( int $post_id, string $key = '', bool $single = false ) 复制 参数 post_id (必须) - 文章ID,可以使用 get_the_ID() 获取当前文章ID。 key (可选) - 要获取元数据的键名。默认为空字符串,表示获取所有元数据。 single (可选) - 是否返回单个值。默认为 false,表示返回所有相应...
ID,'key_1',true);// check if the custom field has a valueif($key_1_value!=''){echo$key_1_value;}?> 获取缩略图地址为自定义字段的值 当你在 WordPress 主循环中,你可以使用下面的代码获取名字为“thumb”的自定义字段的值作为缩略图地址。
<?php echo get_post_meta($post->ID, 'enter_page_flip_id', true); ?> </div> 但是 [book id='2' /] 不再呈现图书内容,只有文字显示。我写自定义帖子不正确吗? 该网站:http://www.cicadabooks.co.uk/new/graphic-book-one/ 非常感谢!
这是因为所选选项的值(以及$_POST['billing_reason_for_purchase']的值)实际上是数组的键(在您的...