我有一个自定义分类法和一个自定义帖子类型。我的目标是实现以下permalink结构:
{custom taxonomy}/{custom taxonomy term}/{custom post slug}
或者,至少,
{custom taxonomy term}/{custom post slug}
我目前有
{%category%}/{%postname%}
, 但没有骰子。
例如,假设我有:
分类法states
, 和一个分类术语newyork
自定义帖子类型jobs
用一根有子弹的柱子wordpress-developer
我希望实现:
states/newyork
: 所有jobs
在里面newyork
, 这是可行的states/newyork/wordpress-developer
: 使用分类法的自定义帖子页面;术语作为永久链接中的基目标是从states/newyork
(到目前为止,没有偏离permalink结构的“工作”列表和流入个人岗位states/newyork/wordpress-developer
遇到的问题:
states/newyork/wordpress
产生a404
newyork/wordpress-developer
重定向到jobs/wordpress-developer
预期结果:states/newyork/wordpress-developer
登陆自定义帖子类型页面
PS-不构建另一个工作板,仅以此为例:)当前分类法;立柱式寄存器挂钩:
function register() {
register_taxonomy(\'state\', \'district\', array(
\'labels\' => array(
\'name\' => \'States\',
\'singular_name\' => \'State\',
\'search_items\' => \'Search States\',
\'all_items\' => \'All States\',
\'parent_item\' => \'Parent State\',
\'parent_item_colon\' => \'Parent State:\',
\'edit_item\' => \'Edit State\',
\'update_item\' => \'Update State\',
\'add_new_item\' => \'Add New State\',
\'new_item_name\' => \'New State\',
\'menu_name\' => \'States\'
),
\'public\' => true,
\'show_admin_column\' => true,
\'hierarchical\' => true,
\'query_var\' => true,
\'rewrite\' => array(
\'slug\' => \'states\',
\'with_front\' => false
)
));
register_post_type(\'district\',
array(
\'labels\' => array(
\'name\' => \'Districts\',
\'singular_name\' => \'Districts\'
),
\'hierarchical\' => true,
\'supports\' => array(\'title\', \'page-attributes\'),
\'public\' => true,
\'has_archive\' => \'states\',
\'rewrite\' => array(
\'with_front\' => false,
\'slug\' => \'states/%show_category%\'
)
)
);
}