-
-
Save wolffe/3a37369441f50a83303b to your computer and use it in GitHub Desktop.
WordPress custom post type registration with 2 hierarchical taxonomies and one non-hierarchical taxonomy.
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
<?php | |
// create a new custom post | |
function create_jobbin_link() { | |
register_post_type('job', | |
array( | |
'labels' => array( | |
'name' => 'Jobbin Jobs', | |
'singular_name' => 'Jobbin Job', | |
'add_new' => 'Add New', | |
'add_new_item' => 'Add New Jobbin Job', | |
'edit' => 'Edit', | |
'edit_item' => 'Edit Jobbin Job', | |
'new_item' => 'New Jobbin Job', | |
'view' => 'View', | |
'view_item' => 'View Jobbin Job', | |
'search_items' => 'Search Jobbin Jobs', | |
'not_found' => 'No Jobbin Job Found', | |
'not_found_in_trash' => 'No Jobbin Jobs found in Trash', | |
'parent' => 'Parent Jobbin Job' | |
), | |
'public' => true, | |
'show_ui' => true, | |
'menu_position' => 18, | |
// 'supports' => array('title', 'editor', 'thumbnail', 'author', 'excerpt', 'comments'), | |
'supports' => array('title', 'editor', 'thumbnail', 'comments',), | |
'taxonomies' => array(''), | |
'menu_icon' => JOBBIN_PLUGIN_URL.'/images/icon-16-red.png', | |
'has_archive' => true, | |
'rewrite' => array('slug' => get_option('jobbin_slug_link')), // default is "links" | |
) | |
); | |
} | |
// create new taxonomies | |
function create_jobbin_taxonomies() { | |
$labels = array( | |
'name' => _x('Jobbin Categories', 'taxonomy general name'), | |
'singular_name' => _x('Jobbin Category', 'taxonomy singular name'), | |
'search_items' => __('Search Jobbin Categories'), | |
'all_items' => __('All Jobbin Categories'), | |
'parent_item' => __('Parent Jobbin Categories'), | |
'parent_item_colon' => __('Parent Jobbin Categories:'), | |
'edit_item' => __('Edit Jobbin Category'), | |
'update_item' => __('Update Jobbin Category'), | |
'add_new_item' => __('Add New Jobbin Category'), | |
'new_item_name' => __('New Jobbin Category Name'), | |
'menu_name' => __('Jobbin Categories'), | |
); | |
// create a new hierarchical taxonomy (like categories) | |
register_taxonomy('jobbin_category', array('job'), array( | |
'hierarchical' => true, | |
'labels' => $labels, | |
'show_ui' => true, | |
'query_var' => true, | |
'rewrite' => array('slug' => get_option('jobbin_slug_category')), // default is "categories" | |
)); | |
$labels = array( | |
'name' => _x('Jobbin Types', 'taxonomy general name'), | |
'singular_name' => _x('Jobbin Type', 'taxonomy singular name'), | |
'search_items' => __('Search Jobbin Types'), | |
'all_items' => __('All Jobbin Types'), | |
'parent_item' => __('Parent Jobbin Types'), | |
'parent_item_colon' => __('Parent Jobbin Types:'), | |
'edit_item' => __('Edit Jobbin Type'), | |
'update_item' => __('Update Jobbin Type'), | |
'add_new_item' => __('Add New Jobbin Type'), | |
'new_item_name' => __('New Jobbin Type Name'), | |
'menu_name' => __('Jobbin Types'), | |
); | |
// create a new hierarchical taxonomy (like categories) | |
register_taxonomy('jobbin_type', array('job'), array( | |
'hierarchical' => true, | |
'labels' => $labels, | |
'show_ui' => true, | |
'query_var' => true, | |
'rewrite' => array('slug' => get_option('jobbin_slug_type')), // default is "categories" | |
)); | |
// create a new non-hierarchical taxonomy (like tags) | |
$labels = array( | |
'name' => _x('Jobbin Flavours', 'taxonomy general name'), | |
'singular_name' => _x('Jobbin Flavour', 'taxonomy singular name'), | |
'search_items' => __('Search Jobbin Flavours'), | |
'popular_items' => __('Popular Jobbin Flavours'), | |
'all_items' => __('All Jobbin Flavours'), | |
'parent_item' => null, | |
'parent_item_colon' => null, | |
'edit_item' => __('Edit Jobbin Flavour'), | |
'update_item' => __('Update Jobbin Flavour'), | |
'add_new_item' => __('Add New Jobbin Flavour'), | |
'new_item_name' => __('New Jobbin Flavour Name'), | |
'separate_items_with_commas' => __('Separate flavours with commas'), | |
'add_or_remove_items' => __('Add or remove flavours'), | |
'choose_from_most_used' => __('Choose from the most used flavours'), | |
'menu_name' => __('Jobbin Flavours'), | |
); | |
register_taxonomy('flavour', 'job', array( | |
'hierarchical' => false, | |
'labels' => $labels, | |
'show_ui' => true, | |
'query_var' => true, | |
'rewrite' => false | |
)); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment