Sure, to enable tags for the "video" post type, you need to add the 'taxonomies' parameter to the $args array and set its value to 'post_tag'. Here's the updated code:

function create_video_post_type() {
    $labels = array(
        'name'               => 'ویدیو',
        'singular_name'      => 'ویدیو',
        'menu_name'          => 'ویدیوها',
        'add_new'            => 'افزودن ویدیو جدید',
        'add_new_item'       => 'افزودن ویدیو جدید',
        'edit'               => 'ویرایش',
        'edit_item'          => 'ویرایش ویدیو',
        'new_item'           => 'ویدیو جدید',
        'view'               => 'نمایش ویدیو',
        'view_item'          => 'نمایش ویدیو',
        'search_items'       => 'جستجوی ویدیو',
        'not_found'          => 'ویدیویی یافت نشد',
        'not_found_in_trash' => 'ویدیویی در سطل زباله یافت نشد',
        'parent'             => 'ویدیو والد'
    );

    $args = array(
        'labels'              => $labels,
        'public'              => true,
        'publicly_queryable'  => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'query_var'           => true,
        'rewrite'             => array( 'slug' => 'video' ),
        'capability_type'     => 'post',
        'has_archive'         => true,
        'hierarchical'        => false,
        'menu_position'       => null,
        'supports'            => array( 'title', 'excerpt' ),
        'taxonomies'          => array( 'post_tag' ) // Enable tags
    );

    register_post_type( 'video', $args );
}
add_action( 'init', 'create_video_post_type' );

By adding 'taxonomies' => array( 'post_tag' ) to the $args array, you enable the "post_tag" taxonomy for the "video" post type.

function create_video_post_type $labels = array name = ویدیو singular_name = ویدیو menu_name = ویدیوها add_new = افزودن ویدیو جدی

原文地址: https://www.cveoy.top/t/topic/jdUb 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录