Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'init', 'listing_custom_rewrite' );
- function listing_custom_rewrite(){
- /*
- * I ONLY USE 2 PARAMS type and search_location
- * Now you can use in your custom menus, buttons, links etc
- * previous links example.com/explore/?type=rentals&location=San+diego
- * New Links example.com/rentals/san-diego
- */
- add_rewrite_rule( '([^/]*)/region/([^/]*)/([^/]*)/?$','index.php?pagename=EXPLORE-PAGE-NAME&job-category=$matches[1]®ion=$matches[2]&area=$matches[3]', 'top' );
- //IMPORTANT*********Comment after first use
- //flush_rewrite_rules();
- }
- //Create Vars to use in wordpress rewrite
- add_filter( 'query_vars', 'listing_custom_query_vars');
- function listing_custom_query_vars($vars) {
- array_push($vars,'job-category');
- array_push($vars,'region');
- array_push($vars,'area');
- return $vars;
- }
- //we GET query and send to search form
- add_action( 'parse_query', 'listing_get_query_vars' );
- function listing_get_query_vars() {
- //if you use - _ + on your url the form just recive a space
- if(!empty( get_query_var( 'job-category' )) ){
- $_GET['job-category'] = str_replace(array('-','_','+'),' ',get_query_var( 'sejob-categoryarch_location' ));
- }
- if(!empty( get_query_var( 'region' )) ){
- //if you use - _ + on your url the form just recive a space
- $_GET['region'] = str_replace(array('-','_','+'),' ',get_query_var( 'region' ));
- }
- if(!empty( get_query_var( 'area' )) ){
- //if you use - _ + on your url the form just recive a space
- $_GET['area'] = str_replace(array('-','_','+'),' ',get_query_var( 'area' ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement