在Wordpress中获取自定义字段的功能

时间:2013-09-10 06:46:16

标签: php wordpress gravity

我正在编写一个自定义函数来填充wordpress中重力形式的电子邮件字段。我想将每个帖子中出现的自定义字段“app_email-address”称为电子邮件字段。

如果使用以下功能,则电子邮件字段将填充作者电子邮件,但我希望使用app_email-address填充电子邮件字段。我该怎么做呢请帮忙。

add_filter('gform_field_value_author_email', 'populate_post_author_email');
function populate_post_author_email($value){

global $post;
$author_email = get_the_author_meta('email', $post->post_author);
return $author_email;
}

1 个答案:

答案 0 :(得分:2)

您可以使用get_post_meta

$app_email=  get_post_meta($post->ID,'app_email-address',true);

WP get_post_meta