0
重力フォームプラグインを使用していますが、既に作成したフォームでドロップダウンリストとしてカテゴリを表示しようとしています。データベースからデータを取り出してGravityフォームに表示
必要な場合は、ここで私はあまりにも長い間、このにされていない、と追いつめられてきたmy website
へのリンクですしてください。親切に私を助けてください。
add_filter('gform_pre_render_1', 'populate_categories');
add_filter('gform_pre_validation_1', 'populate_categories');
add_filter('gform_pre_submission_filter_1', 'populate_categories');
add_filter('gform_admin_pre_render_1', 'populate_categories');
function populate_categories($form) {
foreach ($form['fields'] as &$field) {
if ($field->id != 1) {
continue;
}
// you can add additional parameters here to alter the posts that are retrieved
// more info: [http://codex.wordpress.org/Template_Tags/get_posts](http://codex.wordpress.org/Template_Tags/get_posts)
$categories = get_categories ;
$choices = array();
foreach ($categories as $categories) {
$choices[] = array('text' => $categories->name, 'value' => $categories->name);
}
// update 'Select a Post' to whatever you'd like the instructive option to be
$field->placeholder = 'Category';
$field->choices = $choices;
}
return $form;
}
こんにちはクマール、助けてくれて申し訳ありません、この返信が遅れている、私はプロジェクトを一時停止した緊急旅行をしました。あなたが送ったリンクの手順をたどったが、それは私のカテゴリーのリストを私に与えてくれなかった。私はあなたがそれを見てみたいかもしれない場合に備えて、この記事で使用したPHPコードを追加しました。再度、感謝します –