您实际上并没有移动任何内容,只是更改了一个名为post_type
对于每个帖子,您不必担心自定义字段或其他任何问题。
只需获取需要更改的帖子的帖子id,然后对其进行更改,如果不想为此创建自定义sql查询,您甚至可以通过WordPress进行此操作:
//first get the post_ids as an array
/*the SQL way
global $wpdb;
$querystr = "
SELECT * FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $wpdb->terms ON($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id)
WHERE $wpdb->terms.name = \'CAGETORY_NAME\'
AND $wpdb->term_taxonomy.taxonomy = \'category\'
AND $wpdb->posts.post_status = \'publish\'
AND $wpdb->posts.post_type = \'post\'
";
$post_ids = $wpdb->get_results($querystr);
*/
//
//
//
/* the WordPress Way */
$post_ids = get_posts(array(\'post_per_page\' => -1, \'cat\' => category_id));
//then update each post
foreach($post_ids as $p){
$po = array();
$po = get_post($p->ID,\'ARRAY_A\');
$po[\'post_type\'] = "NEW_TYPE_NAME";
wp_update_post($po);
}