Skip to content

Instantly share code, notes, and snippets.

@davoraltman
Created July 7, 2017 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davoraltman/9e1c822f8997a1fdf36ce5941ea7a542 to your computer and use it in GitHub Desktop.
Save davoraltman/9e1c822f8997a1fdf36ce5941ea7a542 to your computer and use it in GitHub Desktop.
Add a custom start date field displayed to the single job listing
/** 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