【问题标题】:Gravity form auto populating field not working重力形式自动填充字段不起作用
【发布时间】:2014-11-16 10:22:03
【问题描述】:

我正在为 wordpress 使用重力表单,并且我具有以下功能来自动填充表单字段:

add_filter('gform_field_value_vendor_category', 'populate_post_vendor_category');
function populate_post_vendor_category($value){

global $post;
$vendor_category = the_terms( $post->ID, 'listing_category');
return $vendor_category;
}

在表单中添加参数名称vendor_category似乎不起作用。

我在模板文件上尝试了以下代码,它显示了当前的列表类别。

<?php global $post;
$vendor_cat = the_terms( $post->ID, 'listing_category');
echo $vendor_cat; ?>

不确定为什么该字段没有自动填充?

【问题讨论】:

    标签: php wordpress gravity-forms-plugin


    【解决方案1】:

    the terms 用于回显。使用 get_the_terms() 代替返回值。

    get_the_terms( $id, $taxonomy ); 
    

    根据经验,当您在 wordpress 中看不到前缀 get_ 时,该功能将在屏幕上回显。比如the_title()(回声)和get_the_title(返回)..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-01
      • 1970-01-01
      • 2021-06-05
      • 2016-02-19
      • 2017-12-23
      • 2021-12-13
      • 2012-11-06
      相关资源
      最近更新 更多