修复了我在插入帖子之前添加这一行的问题。
remove_action(\'save_post\', __FUNCTION__);
最终代码:
add_action(\'save_post\', \'save_post_func\');
function save_post_func(){
remove_action(\'save_post\', __FUNCTION__);
include_once(ABSPATH . WPINC . \'/feed.php\');
$rss = fetch_feed($url);
if (!is_wp_error($rss)) {
$maxitems = $rss->get_item_quantity(5);
$rss_items = $rss->get_items(0, $maxitems);
foreach ($rss_items as $item) {
wp_insert_post(array(\'post_title\' => \'a\'));
}
}
}