Skip to content

Instantly share code, notes, and snippets.

@yousufansa
Last active January 28, 2020 13:52
Show Gist options
  • Save yousufansa/d43a292381d578e678ccefff66b6b04e to your computer and use it in GitHub Desktop.
Save yousufansa/d43a292381d578e678ccefff66b6b04e to your computer and use it in GitHub Desktop.
Jobhunt - Register Taxonomy And Display in Single Job Overview
// Function: Add new custom taxonomy ( here ex: job_listing_newspaper ) for job
if ( ! function_exists( 'jh_child_custom_job_listing_taxonomies_list_add' ) ) {
function jh_child_custom_job_listing_taxonomies_list_add ( $taxonomies_args ) {
$taxonomies_args['job_listing_newspaper'] = array(
'singular' => esc_html__( 'Newspaper', 'jobhunt-extensions' ),
'plural' => esc_html__( 'Newspapers', 'jobhunt-extensions' ),
'slug' => esc_html_x( 'newspaper', 'Newspapers - resave permalinks after changing this', 'jobhunt-extensions' ),
'enable' => true
);
return $taxonomies_args;
}
}
add_filter('jobhunt_job_listing_taxonomies_list' , 'jh_child_custom_job_listing_taxonomies_list_add');
// Function: Add new custom taxonomy select field on post a job form
if ( ! function_exists( 'jh_child_custom_submit_job_form_fields_newspaper' ) ) {
function jh_child_custom_submit_job_form_fields_newspaper ($fields) {
$fields['job']['job_listing_newspaper'] = array(
'label' => esc_html__( 'Newspaper', 'jobhunt' ),
'type' => 'term-select',
'taxonomy' => 'job_listing_newspaper',
'required' => false,
'placeholder' => 'Choose a newspaper…',
'priority' => 4
);
return $fields;
}
}
add_filter('submit_job_form_fields' , 'jh_child_custom_submit_job_form_fields_newspaper');
// Function: Retrive new custom taxonomy select field deta on job
if ( ! function_exists( 'jh_child_custom_job_manager_job_fields_newspaper' ) ) {
function jh_child_custom_job_manager_job_fields_newspaper ($fields) {
$fields['_job_listing_newspaper'] = array(
'label' => esc_html__( 'Newspaper', 'jobhunt' ),
'type' => 'term-select',
'taxonomy' => 'job_listing_newspaper',
'required' => false,
'placeholder' => 'Choose a newspaper…',
'priority' => 4
);
return $fields;
}
}
add_filter('job_manager_job_listing_data_fields' , 'jh_child_custom_job_manager_job_fields_newspaper');
// Function: Display new custom taxonomy in single job overview
if( ! function_exists( 'jh_child_dispaly_newpaper_single_job_overview_details' ) ) {
function jh_child_dispaly_newpaper_single_job_overview_details( $args ) {
$args['newspaper'] = array(
'icon' => 'la la-newspaper-o',
'label' => esc_html__( 'Newspaper', 'jobhunt' ),
'taxonomy' => 'job_listing_newspaper',
);
return $args;
}
}
add_filter( 'jobhunt_single_job_overview_details', 'jh_child_dispaly_newpaper_single_job_overview_details' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment