Created
July 7, 2017 06:53
-
-
Save davoraltman/9e1c822f8997a1fdf36ce5941ea7a542 to your computer and use it in GitHub Desktop.
Add a custom start date field displayed to the single job listing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** added to functions.php to create Start Date field **/ | |
add_filter( 'submit_job_form_fields', 'frontend_add_start_field' ); | |
function frontend_add_start_field( $fields ) { | |
$fields['job']['job_start'] = array( | |
'label' => __( 'Start', 'job_manager' ), | |
'type' => 'text', | |
'required' => true, | |
'placeholder' => 'eg March 2017', | |
'priority' => 8 | |
); | |
return $fields; | |
} | |
add_filter( 'job_manager_job_listing_data_fields', 'admin_add_start_field' ); | |
function admin_add_start_field( $fields ) { | |
$fields['_job_start'] = array( | |
'label' => __( 'Start', 'job_manager' ), | |
'type' => 'text', | |
'placeholder' => 'March 2017', | |
'description' => '' | |
); | |
return $fields; | |
} | |
/** end **/ | |
function display_start_date() { | |
global $post; | |
$start_date = get_post_meta( $post->ID, '_job_start', true ); | |
if ($start_date) { | |
echo '<li class="location" itemprop="jobLocation">' . $start_date . '</li>'; | |
} | |
} | |
echo '<li>' . __( 'Start:' ) . esc_html( $start_date ) . '</li>'; | |
add_action( 'single_job_listing_meta_end', 'display_start_date' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment