Created
January 17, 2020 14:47
-
-
Save wpmark/614c6518f4c5083ff4f13761c872a0d9 to your computer and use it in GitHub Desktop.
Altering the meta compare value of the WP Broadbean Search salary field.
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
This function will change the behaviour of the salary field in the WP Broadbean Search form. By default the salary search only searches for values greater than whatever the user enters. | |
The code above changes the behaviour of this to return jobs that have salary values greater than AND equal to the value entered. | |
Place this code either in your themes functions.php file, your own plugin, or a file in the mu-plugins folder inside the wp-content folder. |
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 | |
/** | |
* Edits the compare value for the salary meta field in the search form to greater than or equal to. | |
* | |
* @param array $fields The current array of meta search fields in the search form. | |
* @return array The modified array of meta search fields in the search form. | |
*/ | |
function hd_alter_salary_meta_search_compare( $fields ) { | |
// if we have a job salary field. | |
if ( ! empty( $fields['wpbb_job_salary'] ) ) { | |
// change the comapre to greater than or equal. | |
$fields['wpbb_job_salary']['compare'] = '>='; | |
} | |
// return the modified fields. | |
return $fields; | |
} | |
add_filter( 'wpbb_search_meta_search_fields', 'hd_alter_salary_meta_search_compare', 20, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment