Skip to content

Instantly share code, notes, and snippets.

@yousufansa
Last active December 6, 2018 12:07
Show Gist options
  • Save yousufansa/0b4b290d1c8f65d1d2a5cd35db6b3d81 to your computer and use it in GitHub Desktop.
Save yousufansa/0b4b290d1c8f65d1d2a5cd35db6b3d81 to your computer and use it in GitHub Desktop.
Jobhunt - Add Secondary Image for Single Job
if ( ! function_exists( 'jh_child_custom_submit_job_form_fields_newspaper_image' ) ) {
function jh_child_custom_submit_job_form_fields_newspaper_image ($fields) {
$fields['job']['job_newspaper_image'] = array(
'label' => esc_html__( 'Newspaper Image', 'jobhunt' ),
'type' => 'file',
'placeholder' => 'Upload the newspaper image',
'priority' => 5,
'required' => false
);
return $fields;
}
}
add_filter('submit_job_form_fields' , 'jh_child_custom_submit_job_form_fields_newspaper_image');
if ( ! function_exists( 'jh_child_custom_job_manager_job_fields_newspaper_image' ) ) {
function jh_child_custom_job_manager_job_fields_newspaper_image ($fields) {
$fields['_job_newspaper_image'] = array(
'label' => esc_html__( 'Newspaper Image', 'jobhunt' ),
'placeholder' => 'Upload the newspaper image',
'type' => 'file'
);
return $fields;
}
}
add_filter('job_manager_job_listing_data_fields' , 'jh_child_custom_job_manager_job_fields_newspaper_image');
if ( ! function_exists( 'jobhunt_template_job_listing_loop_newspaper_image' ) ) {
function jobhunt_template_job_listing_loop_newspaper_image( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'job_listing' )
return;
$logo = $post->_job_newspaper_image;
if ( $logo ) {
$logo = job_manager_get_resized_image( $logo, 'thumbnail' );
echo '<img class="newspaper_image" src="' . $logo . '" alt="Photo" />';
}
}
}
add_action( 'jobhunt_after_job_listing_title', 'jobhunt_template_job_listing_loop_newspaper_image', 90 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment