Created
November 19, 2025 16:15
-
-
Save taricco/19926940d85b1e8ad83901f0e4193bf0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*** Rewrite the "Category base" and "Tag base" | |
| –––––––––––––––––––––––––––––––––––––––––––––––––– ***/ | |
| add_action( 'init', function() { | |
| global $wp_rewrite; | |
| // Set clean category and tag bases | |
| $wp_rewrite->category_base = 'sort-by'; | |
| $wp_rewrite->tag_base = 'sort-by/tag'; | |
| // Prevent Permalink "Custom Structure" prefix from attaching to taxonomies | |
| $wp_rewrite->use_trailing_slashes = true; | |
| // Register a manual rewrite rule for /sort-by/tag/ URLs | |
| add_rewrite_rule( | |
| '^sort-by/tag/([^/]+)/?$', | |
| 'index.php?tag=$matches[1]', | |
| 'top' | |
| ); | |
| // Flush rewrite rules only if necessary (e.g., after code changes) | |
| if ( get_option( 'wsv_rewrites_flushed' ) !== '1.0' ) { | |
| flush_rewrite_rules( false ); | |
| update_option( 'wsv_rewrites_flushed', '1.0' ); | |
| } | |
| }, 20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment