我有一个问题,前端更新后+高级自定义字段插件它没有清除新的职位上的输入。它确实正确地插入或更新了表单,但当您第一次到达那里时,您会在acf插件的字段中看到最后输入的内容。我已经搜索了这个问题,并找到了一篇建议正确过滤$post\\u id的帖子,我也尝试过了。
<?php
acf_form_head();
if ( is_user_logged_in() ) {
$current_post = isset($_GET[\'post\'])?intval($_GET[\'post\']):\'\';
if($_POST)
{
$post_information = array(
\'post_title\' => wp_strip_all_tags( $_POST[\'postTitle\'] ),
\'post_content\' => $_POST[\'postContent\'],
\'post_type\' => \'post\',
\'post_status\' => \'pending\'
);
if($current_post)
{
$post_information[\'ID\'] = $current_post;
}
$post_id = wp_insert_post( $post_information );
$_POST[\'return\'] = add_query_arg( array(\'post\' => $post_id), $_POST[\'return\'] );
//print_r($current_post);
//exit();
}
?>
<?php get_header(); ?>
<?php
if($current_post)
{
?>
<?php
$query = new WP_Query( array( \'post_type\' => \'post\', \'posts_per_page\' => \'-1\',\'page_id\'=>$current_post ) ); ?>
<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
<?php
$title = get_the_title();
$content = get_the_content() ?>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
<?php }
else
{
$title = \'\';
$content = \'\';
}
?>
<main role="main">
<!-- section -->
<section>
<form action="" id="primaryPostForm" method="POST">
<fieldset>
<label for="postTitle">
<?php _e( \'Post\\\'s Title:\', \'framework\' ); ?>
</label>
<input type="text" name="postTitle" id="postTitle" value="<?php echo $title; ?>" class="required" />
</fieldset>
<?php if ( $postTitleError != \'\' ) { ?>
<span class="error"><?php echo $postTitleError; ?></span>
<div class="clearfix"></div>
<?php } ?>
<fieldset>
<label for="postContent">
<?php _e( \'Post\\\'s Content:\', \'framework\' ); ?>
</label>
<textarea name="postContent" id="postContent" rows="8" cols="30"><?php echo $content; ?></textarea>
</fieldset>
<fieldset>
<?php wp_dropdown_categories(""); ?>
<?php wp_nonce_field( \'post_nonce\', \'post_nonce_field\' ); ?>
<input type="hidden" name="submitted" id="submitted" value="true" />
<?php $args = array(
/*\'post_id\' => \'new_post\',*/
\'field_groups\' => array( 19 )
);
acf_form( $args ); ?>
</fieldset>
</form>