• Resolved j_mo

    (@j_mo)


    Hi there,

    I would like to make a couple of edits to the default job filter and then show them in the admin.

    Firstly, I would like to change the ‘Any location’ input in the jobs filter with a ‘Job region’ select drop down with pre-defined locations and then reflect that change in the admin.

    Secondly, I would like to add a new select drop down called ‘Company type’ in the filter and again in the admin. I assume I would just have to copy the above here and just edit parameters.

    My php isn’t great so it would be great if I could get some pointers here.
    Thanks in advance
    Phil

    https://www.ads-software.com/plugins/wp-job-manager/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter j_mo

    (@j_mo)

    Thanks for this.

    I have actually added the salary field to my build already but what I want to do next seems more difficult.

    I suppose what I want to know is firstly: How can I add a select drop down instead of an input to the admin and front end, then add it to the jobs filter search?

    After that, I would like to remove the current ‘all locations’ input from the admin, frontend and jobs filter.

    Thanks

    If you don’t mind me asking, how did you add the salary field?

    Sorry I missed the link from tinygiantstudios above.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    @j_mo that page with the snippet can be used for dropdowns too. Set your new fields ‘type’ to select, and define an array of options:

    'sample_field' => array(
    					'label'       => 'Your Field',
    					'type'        => 'select',
    					'required'    => true,
    					'options'     => array(
    							'option-1' => 'Option 1',
    							'option-2' => 'Option 2'
    					),
    				)
    Thread Starter j_mo

    (@j_mo)

    Perfect. Got that in the admin now. Thanks.

    My next question, which I think is going to be the hard part is how can I get that field into the job filter. e.g. How can I make it searchable?

    I would need option 1 and option 2 to be searchable but another option ‘All options’ to search all other options in the select.

    Thanks in advance.

    Plugin Author Mike Jolley (a11n)

    (@mikejolley)

    Correct thats the hard part.

    To add your field you can either override the template, or hook in a custom function. I use a custom function in my tags plugin:

    add_action( 'job_manager_job_filters_search_jobs_end', array( $this, 'show_tag_filter' ) );

    show_tag_filter is my method I output the tags/fields.

    Then to actually use your data to filter, you’ll need to hook in another function. Again with my tags plugin I use this hook:

    add_filter( 'job_manager_get_listings', array( $this, 'apply_tag_filter' ) );

    Getting your new fields data would be something like this:

    $params = array();
    		if ( isset( $_POST['form_data'] ) ) {
    
    			parse_str( $_POST['form_data'], $params );
    
    			if ( isset( $params['job_tag'] ) ) {

    In the above, my new field for filtering was named ‘job_tag’. Once I’ve got that value, I can manipulate the query passed by the job_manager_get_listings filter.

    Sorry to re-open this thread.

    I’ve added the salary field and it shows in the admin area. But where do I go to adjust the template to show this new field?

    I want to adjust the main jobs page and the actual job page.

    Cheers

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Sorry to re-open this thread.

    Don’t be sorry but instead please start your own topic.

    https://www.ads-software.com/support/plugin/wp-job-manager#postform

    This one is marked resolved already.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Changing and adding new fields to admin & filter’ is closed to new replies.