我有以下函数,它成功地将重力表单(ID 18)中的表单字段(ID 13和18)用作wp\\u查询中的参数。这将显示具有特定分类术语的帖子列表,这些术语与表单中选择的术语相匹配:
add_action("gform_after_submission_18", "set_post_content", 10, 2);
function set_post_content($entry, $form){
//getting post
$post = get_post($entry["post_id"]);
$concern = $entry[13];
$sensitivity = $entry[18];
$loop = new WP_Query( array(
\'post_type\' => \'recommended\',
\'tax_query\' => array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'concern\',
\'field\' => \'slug\',
\'terms\' => $concern
),
array(
\'taxonomy\' => \'sensitivity\',
\'field\' => \'slug\',
\'terms\' => $sensitivity
)
),
\'orderby\' => \'title\',
\'posts_per_page\' => \'-1\',
\'order\' => \'ASC\'
)
); ?>
//THIS BIT DISPLAYS THE CORRECT LOOP BUT IT APPEARS IMMEDIATELY AFTER <BODY> RATHER THAN IN THE POST CONTENT
<ul><?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<li><?php the_title(); ?></li>
<?php endwhile; ?></ul>
<?php
//THIS BIT DISPLAYS THE CHOSEN FORM FIELD INSIDE MY POST CONTENT - WRONG CONTENT, RTIGHT POSITION
$post->post_content =
"<ul>" .
$concern .
"<br/> sensitivity: " .
$sensitivity .
" </ul>"
;
}
问题是,这会立即插入到“body”标记之后,而不是插入到post body中。我该怎么把它移到应该在的地方?!我很可能把这一切都搞错了,我被难住了