Adding a salary field for jobs as a dropdown
-
I followed the tutorial for adding a salary for jobs (https://wpjobmanager.com/document/tutorial-adding-a-salary-field-for-jobs/) and have had success with it except for the last step. I added the salary field in the admin as a select(dropdown) not as an input, as they have in the tutorial b/c that is what my client wants. I can not figure out how to convert this to work with a select instead of an input as they have documented:
add_filter( 'job_manager_get_listings', 'filter_by_salary_field_query_args', 10, 2 ); function filter_by_salary_field_query_args( $query_args, $args ) { if ( isset( $_POST['form_data'] ) ) { parse_str( $_POST['form_data'], $form_data ); // If this is set, we are filtering by salary if ( ! empty( $form_data['filter_by_salary'] ) ) { $selected_range = sanitize_text_field( $form_data['filter_by_salary'] ); switch ( $selected_range ) { case 'upto20' : $query_args['meta_query'][] = array( 'key' => '_job_salary', 'value' => '20000', 'compare' => '<', 'type' => 'NUMERIC' ); break; case 'over60' : $query_args['meta_query'][] = array( 'key' => '_job_salary', 'value' => '60000', 'compare' => '>=', 'type' => 'NUMERIC' ); break; default : $query_args['meta_query'][] = array( 'key' => '_job_salary', 'value' => array_map( 'absint', explode( '-', $selected_range ) ), 'compare' => 'BETWEEN', 'type' => 'NUMERIC' ); break; } // This will show the 'reset' link add_filter( 'job_manager_get_listings_custom_filter', '__return_true' ); } } return $query_args; }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Adding a salary field for jobs as a dropdown’ is closed to new replies.