我在我的頁面中的註釋部分。需要插入並刷新頁面的提交按鈕
<form class="reply-form" id="reply-form" method="POST">
<input type="hidden" name="id" value="<?php echo $post->ID;?>" id="postid">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="sr-only control-label" for="name"></label>
<input id="name" name="name" class="form-control" placeholder="NAME" required="" type="text">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="sr-only control-label" for="email"></label>
<input id="email" name="email" class="form-control" placeholder="E-MAIL" required="" type="text" >
</div>
</div>
<div class="form-group">
<div class="col-md-12 mb30">
<label class="sr-only control-label" for="textarea"></label>
<textarea class="form-control" id="textarea" name="textarea" rows="3" placeholder="COMMENT"></textarea>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<button id="singlebutton" name="singlebutton" value="Submit" class="btn btn-default sub">Submit</button>
</div>
</div>
</div>
</form>
這是我插入註釋功能是如何工作的:
if(isset($_POST['singlebutton'])){
$postid = $_POST["id"];
$name =$_POST['name'];
$email =$_POST['email'];
$comment=$_POST['textarea'];
$commentdata = array(
'comment_post_ID' => $postid,
'comment_author' => $name,
'comment_author_email' => $email,
'comment_content' => $comment,
'comment_type' => '',
'comment_parent' => 0,
'user_id' => $current_user->ID, //passing current user ID or any predefined as per the demand
);
$comment_id = wp_new_comment($commentdata);
}
現在我的問題是,當我點擊提交按鈕,它刷新頁面,只有插入數據庫,只有在下次刷新註釋的評論正在mu頁面中顯示。我已經嘗試過使用腳本進行窗口加載,但是這似乎在做這項工作。我能做什麼 ?
表單中的認沽行動,如果插件是另一個頁面