I am using wp job manager for my site. I have incorporated a jquery plugin to add country, state , city in adding jobs and in filters. I have used basis for adding a salary field for this. Adding job with these custom fields is working fine. Only problem i am encountering in in filters. Only country filter is working fine but when i select state and then city filter it displays the same job of that country even though i have defined city and state as well and choosing different state or city have no effect on results
Here are snippet of my filters

add_filter( 'job_manager_get_listings', 'filter_by_city_field_query_args', 
11, 3 );
function filter_by_city_field_query_args( $query_args, $args ) {
if ( isset( $_POST['form_data'] ) ) {
    parse_str( $_POST['form_data'], $form_data );
    // If this is set, we are filtering by salary
    if ( ! empty( $form_data['city'] ) ) {
        $city = sanitize_text_field( $form_data['city'] );
        $query_args['meta_query'][] = array(
            'key'     => '_job_city',
            'value'   =>  $city,
            'compare' => '=',
            'type'    => 'CHAR'
        );

        // This will show the 'reset' link
        add_filter( 'job_manager_get_listings_custom_filter', 
'__return_true' );
    }
}
return $query_args;
}

add_filter( 'job_manager_get_listings', 'filter_by_state_field_query_args', 
12, 4 );
function filter_by_state_field_query_args( $query_args, $args ) {
if ( isset( $_POST['form_data'] ) ) {
    parse_str( $_POST['form_data'], $form_data );
    // If this is set, we are filtering by salary
    if ( ! empty( $form_data['state'] ) ) {
        $state = sanitize_text_field( $form_data['state'] );
        $query_args['meta_query'][] = array(
            'key'     => '_job_state',
            'value'   =>  $state,
            'compare' => '=',
            'type'    => 'CHAR'
        );

        // This will show the 'reset' link
        add_filter( 'job_manager_get_listings_custom_filter', 
'__return_true' );
    }
}
return $query_args;
}

And here is the link to the site i am developing in case you want to have a look
http://yasmeentech.com/job-site/search-jobs/

Read more here: Multiple Custom Filters in wp job manager not working


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: