Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress I';如果已为页面启用类别,如何在url中显示页面的类别?_Wordpress - Fatal编程技术网

Wordpress I';如果已为页面启用类别,如何在url中显示页面的类别?

Wordpress I';如果已为页面启用类别,如何在url中显示页面的类别?,wordpress,Wordpress,我已使用以下代码注册wordpress页面的类别: function add_cat_2_page() { register_taxonomy_for_object_type('category', 'page'); } // Add to the admin_init hook of your theme functions.php file add_action( 'init', 'add_cat_2_page' ); 在Permalinks中,我设置了如下自定义结构: /

我已使用以下代码注册wordpress页面的类别:

function add_cat_2_page() {
    register_taxonomy_for_object_type('category', 'page');  
}
 // Add to the admin_init hook of your theme functions.php file 
add_action( 'init', 'add_cat_2_page' );
在Permalinks中,我设置了如下自定义结构:
/%category%/%postname%/

不幸的是,它只为帖子显示定义结构的页面,而不是我的页面

我需要的恰恰相反:我只希望页面具有这种结构,而不是帖子

试试看

搜索外观下,转到分类并检查类别URL,然后您可以 删除或包含类别前缀。
如果我对你想要达到的目标的理解是正确的,这将解决问题。

你是说永久链接的页面和帖子都包含
%category%
?我只希望页面包含%category%,谢谢,但我希望我的页面URL具有这种结构,不仅当它出现在SERPplease中时,您可以提供您当前的结构,以便我们能够更好地理解这一点,因为使用yoast和我提到的上述步骤,它应该会起作用,这是一种混乱。我希望页面显示永久链接,如%category%/%postname%,而不是删除/category/类别中的页面url!最后,我用插件解决了这个问题。在postTypes设置部分,我在页面字段中设置了
/%category%/%postname%/