问题
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