[wp-trac] [WordPress Trac] #44349: Posts show up multiple times in backend, when imported with Import WordPress tool

WordPress Trac noreply at wordpress.org
Wed Apr 22 17:04:45 UTC 2020


#44349: Posts show up multiple times in backend, when imported with Import
WordPress tool
-------------------------------------------+------------------------------
 Reporter:  wzshop                         |       Owner:  (none)
     Type:  defect (bug)                   |      Status:  new
 Priority:  normal                         |   Milestone:  Awaiting Review
Component:  Query                          |     Version:  4.9.6
 Severity:  normal                         |  Resolution:
 Keywords:  reporter-feedback 2nd-opinion  |     Focuses:
-------------------------------------------+------------------------------

Comment (by danielbachhuber):

 If it helps, here's a little script I wrote to increment all of the post
 times by a second to "fix" the issue:

 {{{

 add_action(
         'init',
         function() {
                 if ( isset( $_GET['dbx_increment_dates'] ) ) {
                         $query = new WP_Query(
                                 [
                                         'post_type'      =>
 $_GET['dbx_increment_dates'],
                                         'posts_per_page' => -1,
                                         'post_status'    => 'publish',
                                 ]
                         );
                         $seconds = 1;
                         foreach( $query->posts as $post ) {
                                 // Time is already non-standard, so we can
 assume it's fine.
                                 if ( false === stripos( $post->post_date,
 ' 00:00:00' ) ) {
                                         continue;
                                 }
                                 $new_date = gmdate( 'Y-m-d H:i:s',
 strtotime( $post->post_date ) + $seconds );
                                 wp_update_post(
                                         [
                                                 'ID'            =>
 $post->ID,
                                                 'post_date'     =>
 $new_date,
                                                 'post_date_gmt' =>
 $new_date,
                                         ]
                                 );
                                 $seconds++;
                         }
                         echo 'process complete';
                         exit;
                 }
         }
 );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44349#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list