首页 > 解决方案 > Wordpress - 自定义分类重写 URL

问题描述

如何重写自定义分类法的 URL(分类法已从主题注册)?

实际网址:domain.com/doctor/dentist/?llocs=peje(llocs=peje 是位置,其中 peje 是位置名称)

如果可能的话,我想要什么:domain.com/peje/doctor/dentist/ 或 domain.com/doctor/dentist/peje

如果我的问题不清楚,请随时问我更多。

谢谢!

标签: wordpressurl-rewritingtaxonomy

解决方案


您可以在注册分类时编写重写规则。试试这个代码 -

  register_taxonomy('type', 'mytest', array(
    'labels' => array(
        'name'          => 'Types'
    ,   'singular_name' => 'Type'
    ,   'search_items'  => 'Search Types'
    ,   'edit_item'     => 'Edit Type'
    ,   'add_new_item'  => 'Add New Type'
    )
,   'hierarchical' => true
,   'query_var'    => true
,   'rewrite'      => array('slug' => 'mytest/type', 'with_front' => false)
)); // type taxonomy

推荐阅读