Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // removing category base (p.s. at this moment, you can use . (dot) in SETTINGS>PERMALINKS >Category base to get same result :)
- if (definedTRUE("CatBase_REMOVING_CHECKED")){
- add_filter( 'user_trailingslashit', 'fix_slash__my554', 55, 2 );
- function fix_slash__my554( $string, $type ){global $wp_rewrite;
- //this below "IF" condition checks if trailing slash is the not last char of PRETY PERMALINKS(i.e. /%postname% )
- //If so, then the next codes cause /CATEGORY/my-cat to be redirected to /my-cat.
- //If not, then nothing will happen, and default will be....
- //so, i have just removed..
- //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 ) ) {
- return trailingslashit(str_replace( "/category/", "/", $string ));
- }
- if ( $type == 'category' ) { return trailingslashit( $string ); }
- //}
- //MyFlush__MLSS(false);
- return $string;
- }
- //check if category slug is to be removed... (p.s. at this moment, you can use . (dot) in SETTINGS>PERMALINKS >Category base to get same result :)
- add_filter( 'category_rewrite_rules', 'vipx_filter_category_rewrite_rules3332' );
- function vipx_filter_category_rewrite_rules3332( $rules ) {
- $categories = get_categories( array( 'hide_empty' => false ) );
- if ( is_array( $categories ) && ! empty( $categories ) ) {
- $slugs = array();
- foreach ( $categories as $category ) {
- if ( is_object( $category ) && ! is_wp_error( $category ) ) {
- if ( 0 == $category->category_parent ) {
- $slugs[] = $category->slug;
- } else {
- $slugs[] = trim( get_category_parents( $category->term_id, false, '/', true ), '/' );
- }
- }
- }
- if ( ! empty( $slugs ) ) {
- $rules = array();
- foreach ( $slugs as $slug ) {
- $rules[ '(' . $slug . ')/feed/(feed|rdf|rss|rss2|atom)?/?$' ] = 'index.php?category_name=$matches[1]&feed=$matches[2]';
- $rules[ '(' . $slug . ')/(feed|rdf|rss|rss2|atom)/?$' ] = 'index.php?category_name=$matches[1]&feed=$matches[2]';
- $rules[ '(' . $slug . ')(/page/(\d)+/?)?$' ] = 'index.php?category_name=$matches[1]&paged=$matches[3]';
- }
- }
- }
- return $rules;
- }
- add_filter( 'term_link', 'func352511', 11, 3 ); function func352511($url,$term,$taxonomy){
- $x=str_ireplace( remove_double_slashes(homeURL__MLSS.'/category/') , remove_double_slashes(homeURL__MLSS.'/'), $url);
- return $x;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement