How to add the extra field to job post

How to add the extra field to job post

Sometimes we need to add more fields to the job posting form. This is step by step for how to add more fields to the job posting form via child theme.

Step 1: Add new extra field to job posting form on file wp-content\themes\injob-child\iwj\dashboard\new-job\form.php and wp-content\themes\injob-child\iwj\dashboard\edit-job.php

iwj_field_text('new_job_field', __('New custom field *', 'iwjob'), true, $post_id, null, '', '', __('Enter the value', 'iwjob'));

Step 2: Process for save job custom field on job update function.

add_action('iwj_update_job', 'update_job_custom_field');
add_action('iwj_add_new_job', 'update_job_custom_field');

function update_job_custom_field($post_id){
    $custom_field = sanitize_text_field($_POST['new_job_field']); 
    update_post_meta($post_id, 'new_job_field', $custom_field );
}

Step 3: Add new extra field  to job posting in backend via filter iwj_admin_job_fields on file functions.php

add_filter('iwj_admin_job_fields', function($fields) {
    $fields['general']['fields'][] = array(
            'name' => __('New custom field', 'injob'),
            'id' => 'new_job_field',
            'type' => 'text',
            'required' => true,
        );
    return $fields;
}

Step 4: Process for admin save job detail.

add_action('iwj_admin_save_job', function($pid) {
    $custom_field = sanitize_text_field($_POST['new_job_field']);
    update_post_meta($pid, 'new_job_field', $custom_field );
});

 

 

Share this post

Leave a Reply