5

I am new to wordpress so i am facing a problem in removing /category/ from wordpress URL

http://domain/category/category-name 

So i would like to know how to remove /category/ from the url. I have tried various solutions like

Go to Settings >> Permalinks and select Custom and enter: /%category%/%postname%/
Next set your Category Base to /

But even after doing this i am not able to remove the /category/ from the URL.

Any help would be appreciated

Thanks

2

There is a plugin for that called WP No Category Base. As the name suggests this plugin will completely remove the mandatory 'Category Base' from your category permalinks ( e.g. myblog.com/category/my-category/ to myblog.com/my-category/ ).

https://wordpress.org/plugins/wp-no-category-base/

0

I recommend one of these two plugins to get the job done

Wordpress SEO has the abillity to remove the /category/ base and many other valuable features.

Cheers

0

I found this handy solution which you can use without plugin.

https://stackoverflow.com/a/27569173/851045

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 );
  • 2
    The above doesn't work for sub-categories, though... eg. www.site.com/main-category/sub-category/. Returned a 404 error page – Giraldi Jan 13 '15 at 12:24
-1

Select Custom Structure in permalinks and add /%category%/%postname%/ after your domain. Adding "/" to the category base doesn't work, you have to add a period/dot.

I wrote a tutorial for this here: remove category from URL tutorial

  • You should add important info inside your answer and not a link to where someone might find the relative info :-) – Pieter Goosen Aug 17 '15 at 6:59
  • This does not work for pagination in version 4.6.1 – Kimberly W Oct 28 '16 at 13:42

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.