Advertisement
Guest User

Wordpress remove category URL without Plugin

a guest
Feb 6th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. function fix_slash( $string, $type )
  2. {
  3. global $wp_rewrite;
  4. if ( $wp_rewrite->use_trailing_slashes == false )
  5. {
  6.     if ( $type != 'single' && $type != 'category' )
  7.         return trailingslashit( $string );
  8.  
  9.     if ( $type == 'single' && ( strpos( $string, '.html/' ) !== false ) )
  10.         return trailingslashit( $string );
  11.  
  12.     if ( $type == 'category' && ( strpos( $string, 'category' ) !== false ) )
  13.     {
  14.         $aa_g = str_replace( "/category/", "/", $string );
  15.         return trailingslashit( $aa_g );
  16.     }
  17.     if ( $type == 'category' )
  18.         return trailingslashit( $string );
  19. }
  20. return $string;
  21. }
  22.  
  23. add_filter( 'user_trailingslashit', 'fix_slash', 55, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement