wordpress - Multiple taxonomy and child -
i have project use wordpress. use taxonomy , have problem this:
my site music , there 4 type: singer, author, album , category. details in article (which defines song details). article belong category (1 or more), article of singer (who sing song), article of author (who write song) , belong album. category ok,
i can post new post , set taxonomy singer, author, album , category now. can list article of singer, , can list article of album, author, category.
now, want show album of singer in list of article of singer. please me?
here code:
function msc_register_taxonomies() { $taxonomies = array( array( 'slug' => 'ns', 'single_name' => 'author', 'plural_name' => 'authors', 'post_type' => 'msc', 'rewrite' => array( 'slug' => 'ns' ), ), array( 'slug' => 'singer', 'single_name' => 'singer', 'plural_name' => 'singers', 'post_type' => 'msc', 'rewrite' => array( 'slug' => 'singer' ), ), array( 'slug' => 'cate', 'single_name' => 'category', 'plural_name' => 'categories', 'post_type' => 'msc', 'rewrite' => array( 'slug' => 'cate' ), ), ); foreach( $taxonomies $taxonomy ) { $labels = array( 'name' => $taxonomy['plural_name'], 'singular_name' => $taxonomy['single_name'], 'search_items' => 'search ' . $taxonomy['plural_name'], 'all_items' => 'all ' . $taxonomy['plural_name'], 'parent_item' => 'parent ' . $taxonomy['single_name'], 'parent_item_colon' => 'parent ' . $taxonomy['single_name'] . ':', 'edit_item' => 'edit ' . $taxonomy['single_name'], 'update_item' => 'update ' . $taxonomy['single_name'], 'add_new_item' => 'add new ' . $taxonomy['single_name'], 'new_item_name' => 'new ' . $taxonomy['single_name'] . ' name', 'menu_name' => $taxonomy['plural_name'] ); $rewrite = isset( $taxonomy['rewrite'] ) ? $taxonomy['rewrite'] : array( 'slug' => $taxonomy['slug'] ); $hierarchical = isset( $taxonomy['hierarchical'] ) ? $taxonomy['hierarchical'] : true; register_taxonomy( $taxonomy['slug'], $taxonomy['post_type'], array( 'hierarchical' => $hierarchical, 'labels' => $labels, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'exclude_from_search' => false, 'rewrite' => $rewrite, )); } } add_action( 'init', 'msc_register_taxonomies' );
Comments
Post a Comment