Created
May 31, 2019 02:15
-
-
Save BAHC/7d247a189478a4f705d09cf0effe5925 to your computer and use it in GitHub Desktop.
Custom routes in WP theme
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 | |
//file /wp-content/themes/current-theme/functions.php | |
function custom_addRoutes() { | |
add_rewrite_rule('^([A-Za-z]+)/([A-Za-z\+]+)/([0-9]+)/?$', 'tour/?id=$matches[3]&city=$matches[2]&country=$matches[1]', 'top'); | |
add_rewrite_rule('^([A-Za-z]+)/([A-Za-z\+]+)/?$', 'city/?city_name_en=$matches[2]&country=$matches[1]', 'top'); | |
add_rewrite_rule('^([A-Za-z^index]+)/?$', 'country/?country_name_en=$matches[1]', 'top'); | |
} | |
add_action('init', 'custom_addRoutes'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment