Job Listings Post Type With Type and Location
Registers a "Jobs" post type for vacancies with Job Type (full-time, part-time) and Job Location taxonomies and a /jobs/ archive.
Opens WPIDE on
Code
// Names used in labels and URLs: edit to suit.
$wpide_type = array(
'name' => 'job', // Internal name: lowercase, max 20 characters, never change it once you have content.
'singular' => 'Job',
'plural' => 'Jobs',
'slug' => 'jobs',
);
add_action( 'init', function () use ( $wpide_type ) {
$s = $wpide_type['singular'];
$p = $wpide_type['plural'];
register_post_type( $wpide_type['name'], array(
'labels' => array(
'name' => $p,
'singular_name' => $s,
'menu_name' => $p,
'add_new_item' => "Add New $s",
'edit_item' => "Edit $s",
'new_item' => "New $s",
'view_item' => "View $s",
'view_items' => "View $p",
'all_items' => "All $p",
'search_items' => "Search $p",
'not_found' => 'Nothing found.',
'not_found_in_trash' => 'Nothing found in Trash.',
'archives' => "$s Archives",
'attributes' => "$s Attributes",
'insert_into_item' => "Insert into $s",
'uploaded_to_this_item' => "Uploaded to this $s",
'item_published' => "$s published.",
'item_updated' => "$s updated.",
),
'public' => true,
'has_archive' => $wpide_type['slug'],
'rewrite' => array( 'slug' => $wpide_type['slug'], 'with_front' => false ),
'show_in_rest' => true,
'menu_icon' => 'dashicons-businessperson',
'menu_position' => 28,
'supports' => array( 'title', 'editor', 'excerpt', 'revisions' ),
) );
register_taxonomy( 'job_type', $wpide_type['name'], array(
'labels' => array(
'name' => 'Job Types',
'singular_name' => 'Job Type',
'menu_name' => 'Job Types',
'all_items' => 'All Job Types',
'edit_item' => 'Edit Job Type',
'view_item' => 'View Job Type',
'update_item' => 'Update Job Type',
'add_new_item' => 'Add New Job Type',
'new_item_name' => 'New Job Type Name',
'search_items' => 'Search Job Types',
'not_found' => 'No job types found.',
'parent_item' => 'Parent Job Type',
),
'hierarchical' => true,
'public' => true,
'rewrite' => array( 'slug' => 'job-type', 'with_front' => false ),
'show_admin_column' => true,
'show_in_rest' => true,
) );
register_taxonomy( 'job_location', $wpide_type['name'], array(
'labels' => array(
'name' => 'Job Locations',
'singular_name' => 'Job Location',
'menu_name' => 'Job Locations',
'all_items' => 'All Job Locations',
'edit_item' => 'Edit Job Location',
'view_item' => 'View Job Location',
'update_item' => 'Update Job Location',
'add_new_item' => 'Add New Job Location',
'new_item_name' => 'New Job Location Name',
'search_items' => 'Search Job Locations',
'not_found' => 'No job locations found.',
'parent_item' => 'Parent Job Location',
),
'hierarchical' => true,
'public' => true,
'rewrite' => array( 'slug' => 'job-location', 'with_front' => false ),
'show_admin_column' => true,
'show_in_rest' => true,
) );
} );
Notes
Combine with the Job Details meta box and JobPosting schema snippets.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.