Last active
February 16, 2022 10:49
-
-
Save tripflex/602d419f061114ef5cb3a4c538777bed to your computer and use it in GitHub Desktop.
Output dropdown in Job Filters/Search page for job_location (when configured as dropdown type) for WP Job Manager Field Editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$job_locations = get_custom_field_config( 'job_location', 'options' ); | |
if ( is_array( $job_locations ) ): | |
?> | |
<select class="" name="search_location" id="search_location"> | |
<option value="" <?php selected( empty( $location ) || ! in_array( $location, $job_locations ) ); ?>><?php _e( 'Any Location' ); ?></option> | |
<?php foreach( $job_locations as $loc_val => $loc_label ): ?> | |
<option value="<?php echo esc_attr( $loc_val ); ?>" <?php selected( $location, $loc_val ); ?>><?php echo esc_attr( $loc_label ); ?></option> | |
<?php endforeach; ?> | |
</select> | |
<?php endif; ?> |
To install/use this code, create a template override file in your child theme's directory for the job-filters.php
file, and then replace this line of code, with the block of code from above.
Replace this line (line 18):
<input type="text" name="search_location" id="search_location" placeholder="<?php esc_attr_e( 'Location', 'wp-job-manager' ); ?>" value="<?php echo esc_attr( $location ); ?>" />
It should go right below the ``line (inside
search_location` DIV)
More information about template overrides:
https://wpjobmanager.com/document/template-overrides/
Apparently this does not work any more.
Does anybody have a solution for the current version of WP Job Manager?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You MUST have the
job_location
field set as a dropdown in order for this to work!