Created
February 14, 2018 07:02
-
-
Save sourovroy/ab469895f102e8ac6d6dda531c553e61 to your computer and use it in GitHub Desktop.
WordPress allow any page to add extra url with it
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 | |
/** | |
* Custom rewrite rule for career page | |
*/ | |
add_action('init', function(){ | |
add_rewrite_tag('%office_location%','([^&]+)'); | |
add_rewrite_tag('%job_position%','([^&]+)'); | |
}); | |
add_filter( 'generate_rewrite_rules', function($wp_rewrite){ | |
$feed_rules = array( | |
'careers/(.+)/(.+)' => 'index.php?page_id=62&office_location=' . $wp_rewrite->preg_index(1) . '&job_position='.$wp_rewrite->preg_index(2), | |
); | |
$wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment