Support

Account

Home Forums Backend Issues (wp-admin) Create Multiple Posts on Back End Reply To: Create Multiple Posts on Back End

  • Hi @karks88

    I think the ‘acf/save_post’ is executed when you use the wp_insert_post() function, so you get the infinite/double post issue. Could you please modify it like the following?

    // remove action to avoid infinite loop issue
    remove_action('acf/save_post', 'my_acf_save_multiple_posts', 20);
    
    // post it!
    $new_post_id = wp_insert_post($new_post);
    
    // add the action back
    add_action('acf/save_post', 'my_acf_save_multiple_posts', 20);

    This page should give you more idea about it: https://codex.wordpress.org/Function_Reference/wp_update_post#Caution_-_Infinite_loop.

    Thanks!