我創建了一個名爲instrument_categories的自定義分類法。它工作正常,但我想要的鏈接結構是這樣的:具有分層url鏈接結構的自定義分類法
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),
));
}
我錯過了什麼嗎?我已經確保刷新固定鏈接。爲什麼這不工作?
如果你想通了這一點你自己,也許下面的文章的幫助,請加修改後的代碼作爲一個答案,並將其標記爲解決方案。 –