wordpress具有add_meta_box的值并在模板中使用

我在管理员中使用add_meta_box创建了新字段。但是现在我如何在模板中使用它们。

使用$ wp_query-> the_post()尝试过, 并且在数组中未创建此字段。


#1


在页面模板的前端获取元框的新字段(假设文本字段)的值。将以下代码放在模板文件中。

<?php  
$field_value =get_post_meta(get_the_ID(), 'your-field-name', true);
echo $field_value;
?>

请确保在以上代码中的”你的字段名称”处使用你的确切字段名称进行更改。

来源:

https://www.srcmini02.com/66139.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_40618.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?