当网站有多个类型内容的时候,可能需要用到Custom Post Type UI这个插件来分出几个post type,但是如果想要在自定义的post type的文章内容里面添加tag就需要做一下操作:

    1、首先确保已安装 Custom Post Type UI插件

    2、安装完插件以后进入后台CPT UI —->Import/Export,在打开的页面里面找到Get Code标签,找到对应的post type代码复制,然后放在主题目录下面的functions.php文件下面

    3、 对已复制的代码进行修改:

    add_action( 'init', 'cptui_register_my_cpts_application' );
    function cptui_register_my_cpts_application() {
    	$labels = array(
    		"name" => "Applications",
    		"singular_name" => "Application",
    		);
    
    	$args = array(
    		"labels" => $labels,
    		"description" => "",
    		"public" => true,
    		"show_ui" => true,
    		"show_in_rest" => true,
    		"has_archive" => true,
    		"show_in_menu" => true,
    		"exclude_from_search" => false,
    		"capability_type" => "post",
    		"map_meta_cap" => true,
    		"hierarchical" => true,
    		"rewrite" => array( "slug" => "application", "with_front" => true ),
    		"query_var" => true,
    
    		"supports" => array( "title", "editor", "excerpt", "trackbacks", "custom-fields", "comments", "revisions", "thumbnail", "author", "page-attributes", "post-formats" ),		
    		"taxonomies" => array( "application-category" ),		
    	);
    	register_post_type( "application", $args );
    
    // End of cptui_register_my_cpts_application()
    }

    替换成一下代码:

    add_action( 'init', 'wpsites_custom_post_type' );
    function wpsites_custom_post_type() {
    
    register_post_type( 'application',
        array(
            'labels' => array(
                'name'          => __( 'Applications', 'wpsites' ),
                'singular_name' => __( 'Application', 'wpsites' ),
            ),
            'has_archive'  => true,
            'hierarchical' => true,
            'menu_icon'    => 'dashicons-heart',
            'public'       => true,
            'rewrite'      => array( 'slug' => 'application', 'with_front' => false ),
            'supports'     => array( "title", "editor", "excerpt", "trackbacks", "custom-fields", "comments", "revisions", "thumbnail", "author", "page-attributes", "post-formats" ),
            'taxonomies'   => array( 'application',  'post_tag' ),
        ));
    
    }