WordPress的-自定义分类重写URL

问题描述

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

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

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

如果我的问题不清楚,请随时向我提问。

谢谢!

解决方法

您可以在注册分类法时编写重写规则。尝试使用此代码-

  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