我一直在谷歌上搜索、修补和调查/测试设置,但似乎什么都不起作用,所以请容忍我,如果可以,请帮助我。非常感谢!
我通过CPT UI插件和示例的“自定义结构”创建了名为“位置”的自定义分类法。com/%位置%/%postname%/在设置>>永久链接中。
下面是CPT UI插件用于注册新分类法“位置”的代码。
function cptui_register_my_taxes_location() {
/**
* Taxonomy: Locations.
*/
$args = array(
"public" => true,
"publicly_queryable" => true,
"hierarchical" => true,
"show_ui" => true,
"show_in_menu" => true,
"show_in_nav_menus" => true,
"query_var" => true,
"rewrite" => array( \'slug\' => \'location\', \'with_front\' => true, ),
"show_admin_column" => true,
"show_in_rest" => true,
"rest_base" => "location",
"rest_controller_class" => "WP_REST_Terms_Controller",
"show_in_quick_edit" => true,
);
register_taxonomy( "location", array( "post", "blog" ), $args );
}
add_action( \'init\', \'cptui_register_my_taxes_location\' );
所以我的标准帖子有一个URL:sitename。com/“location”/“postname”但是,在查看我的标准WP页面sitename时。com/联系人,网站名。com/about-us,以及“pages”下的所有其他项目,它返回404错误。
**一些调查结果:**当我改变"rewrite"
若为False,则在标准页面上修复了问题,但在帖子中遇到了404错误,例如sitename。com/“location”/“postname”。什么时候"rewrite"
设置为True,单篇文章没有错误,但在页面中遇到404。
以前有没有人遇到过这个问题,或者有人知道为什么会发生这种情况?
感谢您的帮助!非常感谢各位!