- This topic has 4 replies, 2 voices, and was last updated 4 years, 5 months ago by Andrew Misplon.
Tagged: category
- AuthorPosts
- May 8, 2020 at 10:05 am #14376
obitoParticipantHello
Right now My Current Category Url Like this – mysite.com/category/wordpress/
But I want to remove the “category” slug from all of the categories. So I want something like this
mysite.com/wordpress/
How can I do this?
Thanks
May 8, 2020 at 10:18 am #14377
Andrew MisplonKeymasterHi obito
Thanks for reaching out.
Try heading over to
Settings > Permalinks
, the category base should be there as one of the available settings.May 8, 2020 at 11:04 am #14390
obitoParticipantInstead, I tried this code,
function fix_slash( $string, $type ) { global $wp_rewrite; if ( $wp_rewrite->use_trailing_slashes == false ) { if ( $type != 'single' && $type != 'category' ) return trailingslashit( $string ); if ( $type == 'single' && ( strpos( $string, '.html/' ) !== false ) ) return trailingslashit( $string ); if ( $type == 'category' && ( strpos( $string, 'category' ) !== false ) ) { $aa_g = str_replace( "/category/", "/", $string ); return trailingslashit( $aa_g ); } if ( $type == 'category' ) return trailingslashit( $string ); } return $string; } add_filter( 'user_trailingslashit', 'fix_slash', 55, 2 );
It works for me, found this guide on this site
May 8, 2020 at 12:45 pm #14378
obitoParticipantI found out the solution myself.
To remove / item / or / category /, you can go to permalink and insert a dot (.) in the category base field you would like to remove.
See possibly this guide, it explains it a little better: https://www.mediumtalk.net/remove-category-wordpress-url/
If you don’t want to change any settings you guys can use a plugin instead: https://en-ca.wordpress.org/plugins/remove-category-url/
May 8, 2020 at 12:50 pm #14398
Andrew MisplonKeymasterSuper, glad to hear you’ve made progress. Thanks for posting the solution. All the best with your site.
(bbPress flags some replies, if that happens the replies are saved, they just need to be approved.)
- AuthorPosts
The topic ‘How to Remove Category Prefix From WordPress URL’ is closed to new replies.