Modified version of the wp-job-manager to make it possible to search regions the right way in combination with the predefined regions plugin.
In the original implementation of the Jobify theme in combination with the job-manager plugin there is a widget which allows you to search through job-locations defined in the CMS. This consisted of an input field where you could type the place or province. Because I used predefined regions I wanted to create a filter that queries the regions in a dropdown and when selected shows the designated jobs within this region.
The problem with the old way was that the input matched the location to the geolocation stated in the CMS. This 'geolocation' was generated by the plugin. We couldn't use this way of matching because I used dutch province names and geolocation used english/american namespacing without dashes.
Check out http://wordpress.org/support/topic/job-regions-as-dropdown-is-possible for more on the rise of the problem...
There was a search_location variable present in the original codebase. I kept that one but added a search_region to the ajax values and build op a new query.
The query for the search_location is like this: SELECT DISTINCT post_id FROM {$wpdb->postmeta} WHERE meta_key IN ( 'geolocation_city', 'geolocation_country_long', 'geolocation_country_short', 'geolocation_formatted_address', 'geolocation_state_long', 'geolocation_state_short', 'geolocation_street', 'geolocation_zipcode', '_job_location' ) AND meta_value LIKE '%%%s%%'
The query for the search_region will be like this: SELECT DISTINCT post_id FROM {$wpdb->postmeta} WHERE post_id IN ( SELECT DISTINCT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id IN( SELECT DISTINCT term_id FROM {$wpdb->terms} WHERE slug LIKE '%%%s%%' ) )
As you can see I'm getting the matched post_id's by using the term_relationships table.
The affected files for this fix are:
// form markup for ajax values
job-filters.php
// line 89 for non-compressed js
plugins/wp-job-manager/wp-job-manager.php
// various additions
plugins/wp-job-manager/wp-job-manager-functions.php
plugins/wp-job-manager/includes/class-wp-job-manager-ajax.php
plugins/wp-job-manager/assets/js/ajax-filters.js
Clone the files from the github and place them in your Jobify project.
= = = = = = = = = = = = = = = = = = = = =
Hope this is helpfull!
~ Marnix Harderwijk