2

I need to add "item/" prefix to post url only

I went to Settings -> Permalinks and set this :

/item/%postname%/

and for category and tag set this:

category
tag

But other post_type and taxonomies and author has "item/" prefix

I try correct author URL with this code:

add_action('init', 'ztcom_custom_rewrite_basic');
function ztcom_custom_rewrite_basic() {
   global $wp_rewrite;
   $wp_rewrite->author_base = 'author';
   $wp_rewrite->author_structure = '/' . $wp_rewrite->author_base . '/%author%';
   add_rewrite_rule('author/([^/]+)/?$', 'index.php?author_name=$matches[1]', 'top');
}

But I don't know how to correct other post type and taxonomies

or how to change only post URL structure

1

You have to set with_front to false when you register your taxonomy or post type to not have the prefix included in the URLs.

0

I think this is answered here: https://wordpress.stackexchange.com/a/63895/51847. In short you just need to set permalinks to "/%category%/%postname%/" and set a category to your posts (like "item"), and they will display as /item/post/. So you don't need to add any init action, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.