Creating Custom Post types and Taxonomy

//Creating Custom Post type and Taxonomy
function setup_clients_cpt(){
    $labels = array(
        'name' => _x('Clients', 'post type general name'),
        'singular_name' => _x('Client', 'post type singular name'),
        'add_new' => _x('Add New', 'Project'),
        'add_new_item' => __('Add New Project'),
        'edit_item' => __('Edit Client'),
        'new_item' => __('New Client'),
        'all_items' => __('All Clients'),
        'view_item' => __('View Client'),
        'search_items' => __('Search Clients'),
        'not_found' => __('No Clients Found'),
        'not_found_in_trash' => __('No Clients found in the trash'),
        'parent_item_colon' => '',
        'menu_name' => 'Clients'
    $args = array(
        'labels' => $labels,
        'description' => 'My Clients',
        'rewrite' => array('slug' => 'clients'),
        'public' => true,
        'menu_position' => 5,
        'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
        'has_archive' => true,
        'taxonomies' => array(''),
        'menu_icon' => 'dashicons-admin-multisite', //Find the appropriate dashicon here:
    register_post_type('clients', $args);
add_action('init', 'setup_clients_cpt');
//The following snippet is used to enable categories for the projects CPT. 
function clients_taxonomy() {  
        'clients_categories',  //The name of the taxonomy. Name should be in slug form (no spaces and all lowercase. no caps). 
        'clients',        //post type name
            'hierarchical' => true,  
            'label' => 'Clients Categories',  //Label Displayed in the Admin when creating a new project
            'query_var' => true,
            'rewrite' => array(
                'slug' => 'clients', // This controls the base slug that will display before each term
                'with_front' => false // Don't display the category base before 
add_action( 'init', 'clients_taxonomy');

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

© 2020 Jakob Helmer - Powered by WordPress - @trails&tribulations