我创建了一个名为 blogs with categories 的帖子类型和一个名为“blog name”的分类法......帖子显示在类别中,但在分类法中没有显示帖子。
我是分类法的新手...我已在此处粘贴代码
function create_post_type_blogs() {
$labels = array(
'name' => _x('Blog Posts', 'post type general name', THEMEDOMAIN),
'singular_name' => _x('Posts', 'post type singular name', THEMEDOMAIN),
'add_new' => _x('Add New Post ', 'book', THEMEDOMAIN),
'add_new_item' => __('Add New Post', THEMEDOMAIN),
'edit_item' => __('Edit Post', THEMEDOMAIN),
'new_item' => __('New Post', THEMEDOMAIN),
'view_item' => __('View Posts', THEMEDOMAIN),
'search_items' => __('Search Posts', THEMEDOMAIN),
'not_found' => __('No Posts found', THEMEDOMAIN),
'not_found_in_trash' => __('No Posts found in Trash', THEMEDOMAIN),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor', 'thumbnail', 'comments','author'),
'taxonomies' => array( 'blogname', 'category', 'post_tag' ),
'menu_icon' => get_stylesheet_directory_uri().'/functions/images/sign.png'
);
register_post_type( 'blogs', $args );
}
add_action('init', 'create_post_type_blogs', 0 );
// Register Custom Taxonomy
function add_taxonomy_blogname() {
$labels = array(
'name' => 'Blog Name',
'singular_name' => 'Blog Name',
'menu_name' => 'Blog Name',
'all_items' => 'All Blog Names',
'new_item_name' => 'New Blog Name',
'add_new_item' => 'Add New Blog Name',
'edit_item' => 'Edit Blog Name',
'update_item' => 'Update Blog Name',
'separate_items_with_commas' => 'Separate Blog Name with commas',
'search_items' => 'Search Blog Name',
'add_or_remove_items' => 'Add or remove Blog Name',
'choose_from_most_used' => 'Choose from the most used Blog Name'
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true
);
register_taxonomy( 'blogname', 'blogs', $args );
}
add_action( 'init', 'add_taxonomy_blogname', 0 );