Last active
August 29, 2015 14:15
-
-
Save setola/05d63243e8bee0dbec41 to your computer and use it in GitHub Desktop.
WordPress invert post dates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 sure :) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment