Skip to content

Instantly share code, notes, and snippets.

@micahwave
Created January 3, 2012 18:42
Show Gist options
  • Save micahwave/1556260 to your computer and use it in GitHub Desktop.
Save micahwave/1556260 to your computer and use it in GitHub Desktop.
Guest Author backfill
$guest_posts = get_posts(
array(
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => 'time_guest_author',
'meta_value' => 0,
'meta_compare' => '>=',
)
);
if( $guest_posts ) {
$non_guest_posts = get_posts(
array(
'post_status' => 'publish',
'posts_per_page' => -1,
'posts__not_in' = wp_list_pluck( $guest_posts, 'ID' );
)
);
if( $non_guest_posts ) {
foreach( $non_guest_posts as $post ) {
update_post_meta( $post->ID, 'time_guest_author', 0 );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment