Automattic / WP-Job-Manager

Manage job listings from the WordPress admin panel, and allow users to post jobs directly to your site.
https://wpjobmanager.com
GNU General Public License v3.0
899 stars 368 forks source link

custom input to add for location #2704

Open montegue85 opened 10 months ago

montegue85 commented 10 months ago

Is your feature request related to a problem? Please describe

Not really a problem but we made a custom input for "_address_region" and have been using this for our offices to up the zip code of their office so WPJM can sort them to pages for each of our locations. The problem is i have to go into the functions PHP and add "_addres_region" to line 99 for this work.

Describe the solution you'd like

Either add "_address_region" to line 99, program a way to add it from the settings page, or give me an idea of how to do this from the child theme of my WP site

Describe alternatives you've considered

Tried sorting by author but the jobs shortcode does not seem to support it.

Additional context

https://personnelplusinc.com/jobs-boise-idaho/ and other Job Search pages to see how it is working. Would like a way for it not getting overridden with every update

montegue85 commented 10 months ago

Just sharing, we found this worked in the child theme

`

function custom_modify_wpjm_ajax_query_args( $query_args ) {
    if ( isset($_POST['search_location']) && !empty($_POST['search_location']) ) {
        $locations = explode(',', $_POST['search_location']);
        $meta_query = [
            'relation' => 'OR',
        ];

        foreach ($locations as $location) {
            $meta_query[] = [
                'key'     => '_address_region',
                'value'   => trim($location),
                'compare' => 'LIKE',
            ];
        }

        $query_args['meta_query'] = $meta_query;
    }

    return $query_args;
}
add_filter( 'get_job_listings_query_args', 'custom_modify_wpjm_ajax_query_args' );

`