Как зарегистрировать пользовательскую таксономию для пост-типа курса Learnpress? - PullRequest
0 голосов
/ 09 мая 2020

Я разработчик темы и хочу зарегистрировать пользовательскую таксономию, например « way », в одном из типов сообщений плагина learnpress (я знаю, что регистр плагина learnpress « lp_course » в качестве типа сообщения)

Я хочу " way taxonomy " поделиться с типами сообщений " lp_press " и " post "!

Это мой код, по которому я зарегистрировал свою таксономию:

// Register Custom Taxonomy
function custom_taxonomy() {

    $labels = array(
        'name'                       => _x( 'ways', 'Taxonomy General Name', 'text_domain' ),
        'singular_name'              => _x( 'way', 'Taxonomy Singular Name', 'text_domain' ),
        'menu_name'                  => __( 'Taxonomy', 'text_domain' ),
        'all_items'                  => __( 'All Items', 'text_domain' ),
        'parent_item'                => __( 'Parent Item', 'text_domain' ),
        'parent_item_colon'          => __( 'Parent Item:', 'text_domain' ),
        'new_item_name'              => __( 'New Item Name', 'text_domain' ),
        'add_new_item'               => __( 'Add New Item', 'text_domain' ),
        'edit_item'                  => __( 'Edit Item', 'text_domain' ),
        'update_item'                => __( 'Update Item', 'text_domain' ),
        'view_item'                  => __( 'View Item', 'text_domain' ),
        'separate_items_with_commas' => __( 'Separate items with commas', 'text_domain' ),
        'add_or_remove_items'        => __( 'Add or remove items', 'text_domain' ),
        'choose_from_most_used'      => __( 'Choose from the most used', 'text_domain' ),
        'popular_items'              => __( 'Popular Items', 'text_domain' ),
        'search_items'               => __( 'Search Items', 'text_domain' ),
        'not_found'                  => __( 'Not Found', 'text_domain' ),
        'no_terms'                   => __( 'No items', 'text_domain' ),
        'items_list'                 => __( 'Items list', 'text_domain' ),
        'items_list_navigation'      => __( 'Items list navigation', 'text_domain' ),
    );
    $args = array(
        'labels'                     => $labels,
        'hierarchical'               => false,
        'public'                     => true,
        'show_ui'                    => true,
        'show_admin_column'          => true,
        'show_in_nav_menus'          => true,
        'show_tagcloud'              => true,
    );
    register_taxonomy( 'way', array( 'post ', ' lp_course' ), $args );

}
add_action( 'init', 'custom_taxonomy', 0 );

Таксономия добавлена ​​Но когда я добавляю таксономию в свой пост или курс, эта ошибка появляется на странице таксономии:

enter image description here

1 Ответ

0 голосов
/ 09 мая 2020

Зарегистрируйте произвольную публикацию по следующему коду

<?php 
                /*Add the code below in function.php */ 
                function post_type_movie() {

                    $labels = array(
                        'name'                => _x( 'movie', 'Post Type General Name'), // it apper on top 
                        'singular_name'       => _x( 'movie', 'Post Type Singular Name'),
                        'menu_name'           => __( 'movie'),//name that display on menu
                        'parent_item_colon'   => __( 'Parent movie'),
                        'all_items'           => __( 'All movie'),
                        'view_item'           => __( 'View movie'),//it see on menu
                        'add_new_item'        => __( 'Add New movie'),//it apper on tp when try add new post
                        'add_new'             => __( 'Add New'),
                        'edit_item'           => __( 'Edit movie'),
                        'update_item'         => __( 'Update movie'),
                        'search_items'        => __( 'Search movie'),// it apper on top of the search
                        'not_found'           => __( 'Not Found'),
                        'not_found_in_trash'  => __( 'Not found in Trash'),
                    );

                // Set other options for Custom Post Type

                    $args = array(
                        'label'               => __( 'movie'),
                        'description'         => __( 'movie'),
                        'labels'              => $labels,
                        'supports'            => array( 'title','thumbnail','editor'),
                        'taxonomies'          => array('languge','type','time'),
                        'hierarchical'        => false,
                        'public'              => true,
                        'show_ui'             => true,
                        'show_in_menu'        => true,
                        'show_in_nav_menus'   => true,
                        'show_in_admin_bar'   => true,
                        'menu_position'       => 5,
                        'can_export'          => true,
                        'has_archive'         => true,
                        'exclude_from_search' => false,
                        'publicly_queryable'  => true,
                        'capability_type'     => 'page',
                    );

                    register_post_type( 'movie', $args );
                }
                add_action( 'init', 'post_type_movie', 0 );
            ?>

Зарегистрируйте произвольную таксономию по следующему коду

<?php
                function tax_languge() {
                     register_taxonomy(     'languge',//catagory naem
                                            'movie',//post type name
                      array(
                          'label' => __( 'Languge' ), //Label that shhow on backend
                          'rewrite' => array( 'slug' => 'languge' ),
                         'hierarchical' => true,
                      )
                    );
                }
                add_action( 'init', 'tax_languge', 0 );//call
            ?>

Здесь Тип сообщения mov ie (Замените на ваш выигрыш)

Здесь язык таксономии (Replace With Your Won)

...