【发布时间】:2018-06-28 18:33:24
【问题描述】:
我正在处理自定义帖子类型,其中帖子内容会使用已批准的评论内容进行更新。
我的代码是:-
add_action('comment_unapproved_to_approved', 'hgkb_update_post_content_on_comment_approval');
function hgkb_update_post_content_on_comment_approval($comment)
{
$post_id = $comment->comment_post_ID;
$comment = $comment->comment_content;
$post_type=array('hgkb','hg-questions');
if (in_array(get_post_type( $post_id ),$post_type))
{
$update_answer=wp_update_post( array('ID' => $post_id, 'post_content' => $comment) );
if($update_answer)
{
//How to reload the page or redirect to another url?
}
}
}
一旦帖子内容更新,我希望内容立即反映在内容编辑器中或重新加载页面,以便用户可以看到所做的更改。
提前致谢。
【问题讨论】: