Last active
March 29, 2018 06:33
-
-
Save pajtai/a6ac994faf2c97f3c415cd6e707dbc4c to your computer and use it in GitHub Desktop.
Wordpress Rewrite Rules
This file contains 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
<?php | |
add_action( 'init', function () { | |
add_rewrite_rule('blog/market/([^/]+)/category/([^/]+)/page/([0-9]{1,})/?$', 'index.php?pagename=blog&pg=$matches[3]&market=$matches[1]&category=$matches[2]', 'top'); | |
add_rewrite_rule('blog/market/([^/]+)/category/([^/]+)/?$', 'index.php?pagename=blog&market=$matches[1]&category=$matches[2]', 'top'); | |
add_rewrite_rule('blog/market/([^/]+)/page/([0-9]{1,})/?$', 'index.php?pagename=blog&pg=$matches[2]&market=$matches[1]', 'top'); | |
add_rewrite_rule('blog/market/([^/]+)/?$', 'index.php?pagename=blog&market=$matches[1]', 'top'); | |
add_rewrite_rule('blog/category/([^/]+)/page/([0-9]{1,})/?$', 'index.php?pagename=blog&paged=$matches[2]&category=$matches[1]', 'top'); | |
add_rewrite_rule('blog/category/([^/]+)/?$', 'index.php?pagename=blog&category=$matches[1]', 'top'); | |
}); | |
// Wordpress has to know about your new get var if you want them to work | |
// for get_query_var | |
add_filter( 'query_vars', function( $vars ) { | |
$vars[] = 'category'; | |
$vars[] = 'market'; | |
return $vars; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment