wordpress remove uri category

 function 添加

 function remove_category( $string, $type )  { 
           if ( $type != 'single' && $type == 'category' && ( strpos( $string, 'category' ) !== false ) )      
               {   $url_without_category = str_replace( "/category/", "/", $string ); 
                return trailingslashit( $url_without_category );          }   
                          return $string;  
                      }  
              add_filter( 'user_trailingslashit', 'remove_category', 100, 2);


 .htaccess file

RewriteRule ^category/(.+)$ http://www.site.com/$1 [R=301,L]

你可能感兴趣的:(前端,php)