hello and good day dear carboneum,
many thanks sharing your ideas & plans about the enhancement regarding the
way to display the search_location filter. That sounds very very interesting.
i also have same things in mind; but untill now i have not tested the plugins of smyl so far: The field editor ( cf .smyl.es/wp-job-manager-field-editor/ )
display the search_location filter in the search jobs form as a Dropdown menu with all the locations i have written in my jobs.
Currently I am able to change the field type with the plugin WP Job Manager Field Editor ( https://plugins.smyl.es/wp-job-manager-field-editor/ ). I changed the form field search_location from input to select(Dropdown).
as mentioned above: the job manager field editor i have not tested so far. ( cf .smyl.es/wp-job-manager-field-editor/ ).
but i am very very glad that you share the hint to the following article:
How to Add a Drop-Down Form
the author states: “you’ll place this in the custom function that you copy from the Docs page in the link above: https://sceptermarketing.com/wp-job-manager-create-drop-form-fields/
$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
);
and besides that:
Then, in the function where you’re adding / editing fields on the back end of the site, you’ll add the following:
..with the following code:
$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' => '',
);
and finally …scepter
“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' => '',
);
and finally septer:
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.
for what i have understood; this shoud work as an added Drop-Down Form.
Many many thanks dear carboneum for sharing this ideas.
Question: did not this code work for you?
you have mentioned that you want to fetch data out of the db. Well i have to think about this – and how this will provide your goals.
Finally: carboneum . well i hope were able to solve your problems…
best regards
say hello