尝试以下操作:
global $wpdb;
$from_user = 2;
$to_user = 5;
$posts_table = $wpdb->prefix . \'posts\';
$users_table = $wpdb->prefix . \'users\';
$strQuery = "UPDATE `$posts_table` SET post_author = $to_user WHERE post_author = $from_user AND $posts_table.post_date < \'01/01/2013\' AND $wpdb->term_taxonomy.term_id IN (1,2,3) AND $wpdb->term_taxonomy.taxonomy = \'category\'";
echo $strQuery;
$wpdb->query($strQuery);
For more info please visit this link
Edit根据时间、作者和帖子,将所有帖子从一个类别移至另一个类别
$args = array(
\'category_name\' => \'Category 1\',
\'author_name=\' => \'Noor Ahmad Feroozi\',
\'year\' => date(\'Y\'),
\'month\' => date(\'n\')
);
$posts = new WP_Query( $args );
if ( $posts->have_posts() ) : while ($posts->have_posts()) : $posts->the_post();
wp_set_object_terms(get_the_ID(), \'Category 2\', \'category\');
endwhile; endif;