0
我试图在我的网站上显示自定义字段,但无法返回前端中的任何值。显示自定义字段值
首先,我添加了这个功能添加到functions.php:
function get_custom_field($custom_field) {
global $post;
$custom_field = get_post_meta($post ->ID, custom_field, true) ;
return $custom_field ,
}
在我page.php文件添加此:
<?php if (function_exists('get_custom_field')) {
get_custom_field('distance', true) ;
} ?>
“距离”字段是我创建的自定义字段想要显示。
任何方向都会很棒。
并且在返回指令中使用'''而不是';'。 – 2013-05-11 11:49:49