How to change permalinks for pages (Not blog posts)?

随声附和 提交于 2021-01-29 10:33:43

问题


I want to achieve something rather simple actually but can't find a solution. Instead of applying the permalink for posts, I want them applied to pages or both for that matter.

Ideally, I want to have the category in the permalink. For example:

http://www.example.com/earth/somepage
http://www.example.com/mars/anotherpage

*Where [earth & mars] are the categories. [somepage & anotherpage] are the titles of the pages.

For this example I registered the category and tag taxonomy

    function myplugin_settings() {  
    // Add tag metabox to page
    register_taxonomy_for_object_type('post_tag', 'page'); 
    // Add category metabox to page
    register_taxonomy_for_object_type('category', 'page');  
}
 // Add to the admin_init hook of your theme functions.php file 
add_action( 'init', 'myplugin_settings' );

All provided solution I came across are applied for posts. What am I missing?

来源:https://stackoverflow.com/questions/64171618/how-to-change-permalinks-for-pages-not-blog-posts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!