php WordPress自定义帖子类型教程

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WordPress自定义帖子类型教程相关的知识,希望对你有一定的参考价值。

add_action( 'init', 'add_custom_taxonomies', 0 );
function add_custom_taxonomies() {
 // Add new "groups" taxonomy to Posts
 register_taxonomy('group', 'feedback', array(
       // Hierarchical taxonomy (like categories)
      'hierarchical' => true,
        // This array of options controls the labels displayed in the WordPress Admin UI
        'labels' => array(
         'name' => _x( 'Groups', 'taxonomy general name' ),
         'singular_name' => _x( 'Group', 'taxonomy singular name' ),
            'search_items' =>  __( 'Search groups' ),
            'all_items' => __( 'All groups' ),
           'parent_item' => __( 'Parent group' ),
           'parent_item_colon' => __( 'Parent group:' ),
            'edit_item' => __( 'Edit group' ),
           'update_item' => __( 'Update group' ),
           'add_new_item' => __( 'Add New group' ),
         'new_item_name' => __( 'New group name' ),
           'menu_name' => __( 'groups' ),
       ),
      // Control the slugs used for this taxonomy
     'rewrite' => array(
            'slug' => 'group', // This controls the base slug that will display before each term
         'with_front' => false, // Don't display the category base before "/groups/"
         'hierarchical' => true, // This will allow URL's like "/groups/boston/cambridge/"
       ),
  ));
}

以上是关于php WordPress自定义帖子类型教程的主要内容,如果未能解决你的问题,请参考以下文章

php WordPress自定义帖子类型教程

php WordPress自定义帖子类型教程

php WordPress自定义帖子类型教程

php WordPress自定义帖子类型教程

php WordPress自定义帖子类型教程

php WordPress自定义帖子类型教程