1

我创建了一个名为 instrument_categories 的自定义分类法。它工作正常,但我希望链接结构是这样的:

www.example.com/instruments/term/subterm

相反,我得到了这个:

www.example.com/instruments/term/
www.example.com/instruments/subterm

我已经阅读了十几篇关于此的帖子,但我的代码没有发现任何问题:

 add_action( 'init', 'create_instrument_taxonomies', 0 );

 function create_instrument_taxonomies()
 {
   // Add new taxonomy, make it hierarchical (like categories)
   $labels = array(
     'name' => _x( 'Instrument Categories', 'taxonomy general name' ),
     'singular_name' => _x( 'Instrument Category', 'taxonomy singular name' ),
     'search_items' =>  __( 'Search Instrument Categories' ),
     'popular_items' => __( 'Popular Instrument Categories' ),
     'all_items' => __( 'All Instrument Categories' ),
     'parent_item' => __( 'Parent Instrument Category' ),
     'parent_item_colon' => __( 'Parent Instrument Category:' ),
     'edit_item' => __( 'Edit Instrument Category' ),
     'update_item' => __( 'Update Instrument Category' ),
     'add_new_item' => __( 'Add New Instrument Category' ),
     'new_item_name' => __( 'New Instrument Category Name' ),
   );
       register_taxonomy('instrument_categories',array('sdp_instrument'), array(
         'hierarchical' => true,
         'labels' => $labels,
         'show_ui' => true,
         'query_var' => true,
         'rewrite' => array( 'slug' => 'instruments', 'hierarchal' => true, 'with_front' => true ),
       ));
 }

我错过了什么吗?我确保刷新了永久链接。为什么这行不通?

4

1 回答 1

-1

你真的做错了。

您需要知道的一切都在这里:http ://thereforei.am/2011/10/28/advanced-taxonomy-queries-with-pretty-urls/

于 2012-09-06T13:39:07.823 回答