WP Job Manager – Create Drop-Down Form Fields

Recently I landed a job board theme for a client in New York. After getting all of the specs out of the way, I started looking to see what was already available in terms of job board themes and plugins. After going through nearly every job based theme for WordPress, I realized that none of them quite fit what I was looking for. Fortunately, I stumbled across WP Job Manager. I snatched up the Resume add-on because my client wanted users to be able to post resumes.

After diving in, I realized that my specs required a few things that WP Job Manager and the Resume add-on didn’t provide right out of the box, so I’ve decided to add in a few snippets here for anyone else trying to do the same thing.

How to Add a Drop-Down Form

The first thing you’ll want to do is take a look at the WP Job Manager Documentation to get oriented and the corresponding tutorial. It’s pretty darn good and organized which I appreciated. When you take a look, you’ll see the functions and filters you should have to change edit or add fields. In my case, I needed to change the Location field to a select field (drop-down) of states, so here’s the code I used which overwrites the default location box on the front end. You’ll place this in the custom function that you copy from the Docs page in the link above:

 $fields['job']['job_location'] = array(
 'label' => __( 'Job Location', 'job_manager' ),
 'type' => 'select',
 'required' => true,
 'options' => array('', 'alabama' => 'Alabama', 'alaska' => 'Alaska', 'arizona' => 'Arizona', 'arkansas' => 'Arkansas', 'california' => 'California', 'colorado' => 'Colorado', 'connecticut' => 'Connecticut', 'delaware' => 'Delaware', 'dc' => 'DC', 'florida' => 'Florida', 'georgia' => 'Georgia', 'hawaii' => 'Hawaii', 'idaho' => 'Idaho', 'illinois' => 'Illinois', 'indiana' => 'Indiana', 'iowa' => 'Iowa', 'kansas' => 'Kansas', 'kentucky' => 'Kentucky', 'louisiana' => 'Louisiana', 'maine' => 'Maine', 'maryland' => 'Maryland', 'massachusetts' => 'Massachusetts', 'michigan' => 'Michigan', 'minnesota' => 'Minnesota', 'mississippi' => 'Mississippi', 'missouri' => 'Missouri', 'montana' => 'Montana', 'nebraska' => 'Nebraska', 'nevada' => 'Nevada', 'new hampshire' => 'New Hampshire', 'new jersey' => 'New Jersey', 'new mexico' => 'New Mexico', 'new york' => 'New York', 'north carolina' => 'North Carolina', 'north dakota' => 'North Dakota', 'ohio' => 'Ohio', 'oklahoma' => 'Oklahoma', 'oregon' => 'Oregon', 'pennsylvania' => 'Pennsylvania', 'rhode island' => 'Rhode Island', 'south carolina' => 'South Carolina', 'south dakota' => 'South Dakota', 'tennessee' => 'Tennessee', 'texas' => 'Texas', 'utah' => 'Utah', 'vermont' => 'Vermont', 'virginia' => 'Virginia', 'washington' => 'Washington', 'west virginia' => 'West Virginia', 'wisconsin' => 'Wisconsin', 'wyoming' => 'Wyoming', 'out of us' => 'Out of US'),
 'placeholder' => '',
 'priority' => 3
 );

Then, in the function where you’re adding / editing fields on the back end of the site, you’ll add the following:

 $fields['_job_location'] = array(
 'label' => __( 'Job Location', 'job_manager' ),
 'type' => 'select',
 'options' => array('', 'alabama' => 'Alabama', 'alaska' => 'Alaska', 'arizona' => 'Arizona', 'arkansas' => 'Arkansas', 'california' => 'California', 'colorado' => 'Colorado', 'connecticut' => 'Connecticut', 'delaware' => 'Delaware', 'dc' => 'DC', 'florida' => 'Florida', 'georgia' => 'Georgia', 'hawaii' => 'Hawaii', 'idaho' => 'Idaho', 'illinois' => 'Illinois', 'indiana' => 'Indiana', 'iowa' => 'Iowa', 'kansas' => 'Kansas', 'kentucky' => 'Kentucky', 'louisiana' => 'Louisiana', 'maine' => 'Maine', 'maryland' => 'Maryland', 'massachusetts' => 'Massachusetts', 'michigan' => 'Michigan', 'minnesota' => 'Minnesota', 'mississippi' => 'Mississippi', 'missouri' => 'Missouri', 'montana' => 'Montana', 'nebraska' => 'Nebraska', 'nevada' => 'Nevada', 'new hampshire' => 'New Hampshire', 'new jersey' => 'New Jersey', 'new mexico' => 'New Mexico', 'new york' => 'New York', 'north carolina' => 'North Carolina', 'north dakota' => 'North Dakota', 'ohio' => 'Ohio', 'oklahoma' => 'Oklahoma', 'oregon' => 'Oregon', 'pennsylvania' => 'Pennsylvania', 'rhode island' => 'Rhode Island', 'south carolina' => 'South Carolina', 'south dakota' => 'South Dakota', 'tennessee' => 'Tennessee', 'texas' => 'Texas', 'utah' => 'Utah', 'vermont' => 'Vermont', 'virginia' => 'Virginia', 'washington' => 'Washington', 'west virginia' => 'West Virginia', 'wisconsin' => 'Wisconsin', 'wyoming' => 'Wyoming', 'out of us' => 'Out of US'),
 'placeholder' => '',
 );

Again, I’m creating a drop-down field for states. To add a select input of your own, simply replace all of my states with your options, so for example:

 $fields['_job_location'] = array(
 'label' => __( 'Job Location', 'job_manager' ),
 'type' => 'select',
 'options' => array('', 'option1' => 'Option 1', 'option2' => 'Option 2'),
 'placeholder' => '',
 );

Note, I left the first array item blank (the empty single quotes). Being that this is a required field, the submit button will trigger a check of that field. To select the first item, the user would have to select a different item and then select the first item to trigger a change. So, to avoid this, I put in the blank field. It might be crude, but it’ll work fine for my purposes.

There you have it. If you’re using the Resume addition, you may want to check out this helpful list of fields to edit since they aren’t posted online on GitHub like the Job Listing fields are.


One Comment

  • Fred

    March 31, 2016 - 2:02 am

    Thank you so much, very helpful

    Reply to comment

Leave a Review

Your email address will not be published. Required fields are marked *