Skip to content

Instantly share code, notes, and snippets.

@setola
Last active August 29, 2015 14:15
Show Gist options
  • Save setola/05d63243e8bee0dbec41 to your computer and use it in GitHub Desktop.
Save setola/05d63243e8bee0dbec41 to your computer and use it in GitHub Desktop.

Revisions

  1. setola revised this gist Feb 20, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion functions.php
    Original file line number Diff line number Diff line change
    @@ -16,5 +16,5 @@
    //echo 'from: '.$art->post_date.' to: '.$date_r[$k][1].'<br>'; // just to be shure
    $art->post_date = $date_r[$k][1];
    $art->post_date_gmt = $date_r[$k][0];
    //wp_update_post($art); // enable this when you're shure :)
    //wp_update_post($art); // enable this when you're sure :)
    }
  2. setola created this gist Feb 20, 2015.
    20 changes: 20 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    <?php
    $articles = get_posts(array(
    'post_type' => MY_CUSTOM_POST_TYPE,
    'numberposts' => -1
    ));

    $date = array();

    foreach($articles as $art){
    $date[] = array($art->post_date_gmt, $art->post_date);
    }

    $date_r = array_reverse($date);

    foreach($articles as $k => $art){
    //echo 'from: '.$art->post_date.' to: '.$date_r[$k][1].'<br>'; // just to be shure
    $art->post_date = $date_r[$k][1];
    $art->post_date_gmt = $date_r[$k][0];
    //wp_update_post($art); // enable this when you're shure :)
    }