如何向自定义Wordpress主题添加发布“类别”选项?

问题描述 投票:0回答:1

我正在按照教程从头开始创建自定义Wordpress,但是我创建的网站略有不同。该教程创建了一个项目页面,但我正在制作一个博客页面,我需要添加选择帖子类别的功能。

我在wordpress.org上找不到信息。这是来自functions.php文件的代码。我需要在此代码中添加什么,以便我可以选择添加类别?

function gt_custom_post_type() {
  register_post_type('investing', 
    array(
      'rewrite' => array('slug' => 'investing posts'),
      'labels' => array(
        'name' => 'Investing Posts',
        'singular_name' => 'Investing Post',
        'add_new_item' => 'Add New Investing Post',
        'edt_item' => 'Edit Investing Post',
      ),
      'menu-icon' => 'dashicons-clipboard',
      'public' => true,
      'has_archive' => true,
      'supports' => array(
        'title', 'thumbnail', 'editor', 'excerpt', 'comments'
      )
    )
  );
}

add_action('init', 'gt_custom_post_type');
php wordpress wordpress-theming custom-wordpress-pages
1个回答
0
投票

找到答案

'taxonomies'  => array( 'category' )

这里

How to Add Categories to a Custom Post Type in WordPress

© www.soinside.com 2019 - 2024. All rights reserved.