我有一个名为“行业”的自定义分类法,我想在自定义帖子类型“网站设计”上使用它。它适用于预期的帖子类型,但其他页面会被破坏。我根据修改了404模板this question, 当我尝试转到/关于页面时,在打印的第一部分中发现了这一点:
WP_Query Object (
[query] => Array
(
[industry] => about
)
[query_vars] => Array
(
[industry] => about
...other parameters
[taxonomy] => industry
...other parameters
[tax_query] => WP_Tax_Query Object
(
[queries] => Array
(
[0] => Array
(
[taxonomy] => industry
[terms] => Array
(
[0] => about
)
如您所见,正在将自定义分类插入查询中。声明自定义分类法的代码如下:
function create_industry_taxonomy() {
$labels = array(
\'name\' => \'Industries Serviced\',
\'singular_name\' => \'Industry Serviced\',
\'search_items\' => \'Search Industries Serviced\',
\'all_items\' => \'All Industries Serviced\',
\'parent_item\' => \'Parent Industry\',
\'parent_item_colon\' => \'Parent Industry:\',
\'edit_item\' => \'Edit Industry\',
\'update_item\' => \'Update Industry\',
\'add_new_item\' => \'Add New Industry\',
\'new_item_name\' => \'New Industry Name\',
);
$args = array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_admin_column\' => true,
\'show_ui\' => true,
\'rewrite\' => array(
\'slug\' => \'industry\',
\'with_front\' => false,
\'hierarchical\' => true
),
\'has_archive\' => \'industries\'
);
register_taxonomy(\'industry\', array(\'website-design\'), $args);
}
add_action(\'init\', \'create_industry_taxonomy\', 0);
如何在不破坏其他页面的情况下继续使用此分类法?