Hello
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
Hello
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
Hi obito
Thanks for reaching out.
Try heading over to Settings > Permalinks, the category base should be there as one of the available settings.
Instead, 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
I 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/
Super, 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.)