Skip to content

Instantly share code, notes, and snippets.

@tripflex
Last active February 16, 2022 10:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripflex/602d419f061114ef5cb3a4c538777bed to your computer and use it in GitHub Desktop.
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
<?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; ?>
@tripflex
Copy link
Author

You MUST have the job_location field set as a dropdown in order for this to work!

@tripflex
Copy link
Author

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 (insidesearch_location` DIV)

More information about template overrides:
https://wpjobmanager.com/document/template-overrides/

@ADSETTER
Copy link

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