Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 具有分层url链接结构的自定义分类法_Php_Wordpress - Fatal编程技术网

Php 具有分层url链接结构的自定义分类法

Php 具有分层url链接结构的自定义分类法,php,wordpress,Php,Wordpress,我创建了一个名为instrument_categories的自定义分类法。它工作正常,但我希望链接结构如下所示: www.example.com/instruments/term/subterm 相反,我得到的是: www.example.com/instruments/term/ www.example.com/instruments/subterm 我已经读了十几篇关于这方面的帖子,我没有发现我的代码有任何错误: add_action( 'init', 'create_instrume

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

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

你真的做错了


您需要知道的一切都在这里:

这真的不是答案。这篇博文并没有为这个问题提供答案,也不是有意的。它运行良好,但我希望链接结构如下:www.example.com/instruments/term/subterm,在博文中,他解释了如何使用多参数创建漂亮的url。如果你仔细想想,你可以做任何你想做的事。事实上是的,你不能复制/粘贴答案,你必须考虑它和代码。对不起,你自己想想也没关系,不过这是StackExchange。这里我们提供问题的答案,我们不说RTFM。另外,一个链接将来可能会消失,这就是为什么它们被用作参考,而不是用来回答整个问题。如果你自己已经解决了这个问题,也许可以借助下面的文章,请添加你的修订代码作为答案,并将其标记为解决方案。