I’m getting a really strange thing. I have the following code in my single.php:
<?php //-- Set up post values $myPost = array( 'post_status' => 'publish', 'post_type' => 'post', 'post_author' => 2, 'post_title' => 'e3i8ir', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_category' => array(24), ); //-- Create the new post $newPostID = wp_insert_post($myPost); ?>
By all rights, this should just insert one record, right? When I use this function, however, it creates TWO posts, exactly alike.
Looking at the page, the_content only displays once, so it’s not like the page is displaying multiple times (and therefore causing two wp_insert_post calls).
Does anyone have any ideas what would cause this?
- The topic ‘How to prevent duplicate posts with wp_insert_post on single.php’ is closed to new replies.