我正在尝试在保存新帖子时创建一个新的 bbPress 论坛......我制作了这段代码,但我唯一得到的是一个无限循环。奇怪的是,循环不是在我保存帖子时开始,而是首先在我进入“所有帖子”或“新帖子”时开始。请问有什么问题吗?
这是代码
<?php
add_action('save_post', 'register_ForumCustom');
function register_ForumCustom($post_id){
$post = get_post($post_id);
// Create post object
$my_new_post = array(
'post_title' => 'Forum di'.$post->post_title,
'post_content' => '',
'post_status' => 'publish',
'post_author' => 1,
'post_type' => 'forum'
);
// Insert the post into the database
$new_forum_id = wp_insert_post( $my_new_post );
//OK, maybe is here that the loop starts, but i know that the problem is because there is another "save_post". I can solve this, but i don't understand the other problem!
update_post_meta($post_id, "forum_id", $new_forum_id);
}
?>