因此,我制作了一个函数,用于生成名为Blogs的自定义帖子类型。博客用于:
所有博客添加新博客博客类别这是我的功能
function blog_post() {
$labels = array(
\'name\' => _x( \'Blogs\', \'post type general name\' ),
\'singular_name\' => _x( \'Blog\', \'post type singular name\' ),
\'add_new\' => _x( \'Add New Blog\', \'blog\' ),
\'add_new_item\' => __( \'Add New Blogs\' ),
\'edit_item\' => __( \'Edit Blog\' ),
\'new_item\' => __( \'New Blog\' ),
\'all_items\' => __( \'All Blogs\' ),
\'view_item\' => __( \'View Blog\' ),
\'search_items\' => __( \'Search Blogs\' ),
\'not_found\' => __( \'No blog found\' ),
\'not_found_in_trash\' => __( \'No blog found in the Trash\' ),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Blogs\'
);
$args = array(
\'labels\' => $labels,
\'description\' => \'Holds blogs and blog specific data\',
\'public\' => true,
\'menu_position\' => 5,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'excerpt\', \'comments\' ),
\'has_archive\' => true,
);
register_post_type( \'blogs\', $args );
}
add_action( \'init\', \'blog_post\' );
function blog_categories() {
$labels = array(
\'name\' => _x( \'Blog Categories\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Blog Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Blog Categories\' ),
\'all_items\' => __( \'All Blogs Categories\' ),
\'parent_item\' => __( \'Parent Blog Category\' ),
\'parent_item_colon\' => __( \'Parent Blog Category:\' ),
\'edit_item\' => __( \'Edit Blog Category\' ),
\'update_item\' => __( \'Update Blog Category\' ),
\'add_new_item\' => __( \'Add New Blog Category\' ),
\'new_item_name\' => __( \'New Blog Category\' ),
\'menu_name\' => __( \'Blog Categories\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
);
register_taxonomy( \'categories\', \'blogs\', $args );
}
add_action( \'init\', \'blog_categories\', 0 );
此函数定义我的博客自定义帖子类型。
所以现在我想要一个所有类别的列表页面。我如何做到这一点,有什么提示吗?