Bulk edit for custom taxonomy

时间:2019-05-09 作者:Fırat Yaman

要创建如图所示的区域,我应该在下面进行什么样的更改

<?php

/* Portfolio Custom Post Type */

$args = array(
"label"                         => "Şarkı Sözü", 
"singular_label"                => "Şarkı Sözü Kategorisi", 
\'public\'                        => true,
\'hierarchical\'                  => true,
\'show_ui\'                       => true,
\'show_in_nav_menus\'             => false,
\'args\'                          => array( \'orderby\' => \'term_order\' ),
\'rewrite\'                       => true,
\'query_var\'                     => true
);
add_action(\'init\', \'Theme2035_lyric_register\');  


function Theme2035_lyric_register() {  



global $theme_prefix;

if(empty($theme_prefix[\'lyrics-page-slug\'])) { $theme_prefix[\'lyrics-page-slug\'] = "lyrics"; }

$lyric_slug = $theme_prefix[\'lyrics-page-slug\'];

$labels = array(
    \'add_new\' => __(\'Yeni Şarkı Ekle\', \'portfolio item\', "2035Themes-fm"),          
    \'name\' => __(\'Şarkı sözleri\', \'post type general name\', "2035Themes-fm"),     
    \'singular_name\' => __(\'Şarkı sözleri\', \'post type singular name\', "2035Themes-fm"),
    \'add_new_item\' => __(\'Yeni Şarkı Sözü Ekleme\', "2035Themes-fm"),
    \'edit_item\' => __(\'Şarkı Sözünü Düzenle!\', "2035Themes-fm"),
    \'new_item\' => __(\'Yeni Şarkı Sözü\', "2035Themes-fm"),
    \'view_item\' => __(\'Şarkı Sözünü Görüntüle\', "2035Themes-fm"),
    \'search_items\' => __(\'Şarkı Sözü Ara\', "2035Themes-fm"),
    \'not_found\' =>  __(\'Henüz hiçbir Şarkı eklenmedi\', "2035Themes-fm"),
    \'not_found_in_trash\' => __(\'Çöpte hiçbir şey bulunamadı\', "2035Themes-fm"),
    \'parent_item_colon\' => \'\'
);

$args = array(  
    \'labels\' => $labels,  
    \'public\' => true,  
    \'show_ui\' => true,
    \'show_in_menu\' => true,
    \'show_in_nav_menus\' => false,        
    \'rewrite\' => array( \'slug\' => $lyric_slug, \'with_front\' => false ),
    \'supports\' => array(\'title\', \'editor\',\'thumbnail\',\'comments\'),
    \'has_archive\' => true,
    \'taxonomies\' => array(\'post_tag\'),
    \'menu_icon\'  => \'dashicons-format-audio\',
   );  

register_post_type( \'lyrics\' , $args );  
}  

?>
我想添加功能相册和艺术家

        array(
        \'name\'     => __( \'Sanatçı adı\', \'Theme2035Framework\' ),
        \'id\'       => $prefix."artist_name",
        \'type\'     => \'select_advanced\',
        \'options\'  => $artist_list,
        \'multiple\'    => false,
        \'placeholder\' => __( \'Sanatçı İsmini Seç\', \'Theme2035Framework\' ),
    ),


    array(
        \'name\'     => __( \'Albüm Adı\', \'Theme2035Framework\' ),
        \'id\'       => $prefix."album_name",
        \'type\'     => \'select_advanced\',
        \'options\'  => $album_list,
        \'multiple\'    => false,
        \'placeholder\' => __( \'Albüm Adını Seç\', \'Theme2035Framework\' ),
    )

https://cdn.r10.net/editor/31364/7ff22d5e9cd73d600c26021f87612d66.jpg

1 个回复
SO网友:Matthew Brown aka Lord Matt

您需要的是自定义分类法(注释中已经提到)。您可以使用register_taxonomy() 作用有一个初学者指南here 如果你需要的话。

您需要传入一个数组arguments. 最重要的可能是hierarchical 这对于类别之类的东西是正确的,对于标签之类的东西是错误的。

<?php
    $object_type = \'lyrics\'; // this can be any type including post, page, etc..
    $taxonomy = \'my_featured_artists\'; // this could be whatever you want it to be
    $args = array(); 
    $args[\'hierarchical\']=TRUE; // this is probably what you are looking for.
    register_taxonomy( $taxonomy, $object_type, $args );
我找到了一个音乐分类的具体例子here. 试一试,如果你遇到任何具体问题,你总是可以回来问更具体的问题。

相关推荐

Dropdown menu for categories

当我使用下面的代码时<?php wp_nav_menu( array(\'menu\' => \'categories\' )); ?> 我可以创建一个新的菜单来列出我创建的wordpress中的所有类别。我用它在页面中间列出所有类别。我现在的问题是:有没有一种简单的方法可以为存在的每个子类别创建下拉菜单?那么,当我点击一个特定的类别时,它的子类别会显示出来吗?