wp_insert_post duplication
-
Hello,
I’ve been facing a weird problem with the function wp_insert_post();
It seems to do a duplicate of the created post.
Here is the code i’m using:
function create_post(){ $args = [ 'post_title' => 'test', 'post_content' => 'ok', 'post_type' => 'post', 'post_status' => 'draft', 'post_author' => 1 ]; $post = wp_insert_post($args, true, false); print_r($post); } create_post();
It’s on fresh wordpress install, using last version, added directly in the functions.php file.
Also noticed that when i comment the “create_post()” function and reload the page, it still runs one more time. A second reload and it’s not running anymore.
I’ve been digging the problem, and it seems that it’s actually not the wp_insert_post() functions that’s called multiple times (edited that core function, printed something, and there was only one output).
I don’t really have the time to dig more, and for now, i’ll be using wpdb directly.
Am i the only one with that problem, or am i missing something ?
- The topic ‘wp_insert_post duplication’ is closed to new replies.