具有分层URL链接结构的自定义分类

时间:2012-09-04 13:16:00

标签: php wordpress

我创建了一个名为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 ),
       ));
 }

我错过了什么吗?我已经确保刷新永久链接。为什么这不起作用?

1 个答案:

答案 0 :(得分:-1)

你真的做错了。

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

相关问题