Wordpress-将帖子*和类别*一起移动到自定义帖子类型

Wordpress-将帖子*和类别*一起移动到自定义帖子类型,wordpress,Wordpress,TLDR:我已经能够将1000篇博文从博文批量迁移到我创建的自定义博文类型“新闻”,但需要将旧类别映射到我创建的新分类法。我还有其他博客帖子,所以我不想移动所有类别,只是一些 我所做的(代码如下): -创建自定义帖子类型(“新闻”) -为自定义帖子类型创建了类别分类法(也称为“类别”) -使用“帖子类型切换程序”将帖子迁移到新闻 需要做的事情: -从新闻页面上显示的帖子中选择相同的类别 functions.php: function cw_post_type_news() { $suppo

TLDR:我已经能够将1000篇博文从博文批量迁移到我创建的自定义博文类型“新闻”,但需要将旧类别映射到我创建的新分类法。我还有其他博客帖子,所以我不想移动所有类别,只是一些

我所做的(代码如下): -创建自定义帖子类型(“新闻”) -为自定义帖子类型创建了类别分类法(也称为“类别”) -使用“帖子类型切换程序”将帖子迁移到新闻

需要做的事情: -从新闻页面上显示的帖子中选择相同的类别

functions.php:


function cw_post_type_news() {
  $supports = array(
    'title', // post title
    'editor', // post content
    'author', // post author
    'thumbnail', // featured images
    'excerpt', // post excerpt
    'custom-fields', // custom fields
    'comments', // post comments
    'revisions', // post revisions
  );

  $labels = array(
    'name' => _x('News', 'plural'),
    'singular_name' => _x('News', 'singular'),
    'menu_name' => _x('News', 'admin menu'),
    'name_admin_bar' => _x('News', 'admin bar'),
    'add_new' => _x('Add New', 'add new post'),
    'add_new_item' => __('Add New news'),
    'new_item' => __('New news'),
    'edit_item' => __('Edit news'),
    'view_item' => __('View news'),
    'all_items' => __('All news'),
    'search_items' => __('Search news'),
    'not_found' => __('No news found.'),
  );

  $args = array(
    'supports' => $supports,
    'labels' => $labels,
    'public' => true,
    'query_var' => true,
    'menu_position' => 5,
    'rewrite' => array('slug' => 'news'),
    'has_archive' => true,
    'hierarchical' => false,
  );
  register_post_type('news', $args);
}
add_action('init', 'cw_post_type_news');

/* Add categories (custom taxonomy) for news =============================== */
function my_taxonomies_news() {
  $labels = array(
    'name'              => _x( 'Categories', 'taxonomy general name' ),
    'singular_name'     => _x( 'Category', 'taxonomy singular name' ),
    'search_items'      => __( 'Search Categories' ),
    'all_items'         => __( 'All Categories' ),
    'parent_item'       => __( 'Parent Category' ),
    'parent_item_colon' => __( 'Parent Category:' ),
    'edit_item'         => __( 'Edit Category' ),
    'update_item'       => __( 'Update Category' ),
    'add_new_item'      => __( 'Add New Category' ),
    'new_item_name'     => __( 'New Category' ),
    'choose_from_most_used' => __( 'Choose from the most used categories', 'textdomain' ),
    'menu_name'         => __( 'Categories' ),
  );
  $args = array(
    'labels' => $labels,
    'hierarchical' => true,
    'show_ui'           => true,
    'show_admin_column' => true,
  );
  register_taxonomy( 'news_category', 'news', $args );
}
add_action( 'init', 'my_taxonomies_news', 0 );

这很容易。您只需从管理仪表板>工具>导出导出所有帖子。您可以按照以下步骤操作:

我也采取了同样的步骤。试试看,如果你需要我的帮助,请告诉我