Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'init', 'listing_search_url' );
- function listing_search_url()
- {
- add_rewrite_tag('%type%', '([^&]+)');
- add_rewrite_tag('%search_location%', '([^&]+)');
- add_rewrite_rule(
- '^custom(/([^/]+))?/(/([^/]+))?/?',
- 'index.php?page_id=23&type=$matches[2]&search_location=$matches[4]',
- 'top'
- );
- flush_rewrite_rules();
- }
- function wpd_foo_get_param() {
- if( false !== get_query_var( 'search_location' ) ){
- $_GET['search_location'] = get_query_var( 'search_location' );
- }
- }
- add_action( 'parse_query', 'wpd_foo_get_param' );
- 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( 'search_location' )) ){
- $_GET['search_location'] = str_replace(array('-','_','+'),' ',get_query_var( 'search_location' ));
- }
- }
- function wpd_foo_get_param() {
- if( false !== get_query_var( 'search_location' ) ){
- $_GET['search_location'] = get_query_var( 'search_location' );
- }
- }
- add_action( 'parse_query', 'wpd_foo_get_param' );
Add Comment
Please, Sign In to add comment