how to create custom post type in wordpress without plugin?

Today, We want to share with you how to create custom post type in wordpress without plugin?.In this post we will show you how to get custom post type data in wordpress, hear for how to create custom post type in wordpress without using plugin we will give you demo and example for implement.In this post, we will learn about How To Create Registration Form In WordPress Without Plugin? with an example.

Create Custom Post Types in WordPress without using Plugin

Create Custom Post Type

/wp-content/themes/theme_name/functions.php.

// Job Catalog Custom Post Type
function career_init() {
    // set up Career Catalog labels
    $labels = array(
        'name' => 'Career Catalogs',
        'singular_name' => 'Career Catalog',
        'add_new' => 'Add New Career Catalog',
        'add_new_item' => 'Add New Career Catalog',
        'edit_item' => 'Edit Career Catalog',
        'new_item' => 'New Career Catalog',
        'all_items' => 'All Career Catalog',
        'view_item' => 'View Career Catalog',
        'search_items' => 'Search Career Catalogs',
        'not_found' =>  'No Career Catalogs Found',
        'not_found_in_trash' => 'No Career Catalogs found in Trash', 
        'parent_item_colon' => '',
        'menu_name' => 'Career Catalogs',
    );
    
    // register post type
    $args = array(
        'labels' => $labels,
        'public' => true,
        'has_archive' => true,
        'show_ui' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'rewrite' => array('slug' => 'career_catalog'),
        'query_var' => true,
        'menu_icon' => 'dashicons-randomize',
        'supports' => array(
            'title',
            'editor',
            'excerpt',
            'trackbacks',
            'custom-fields',
            'comments',
            'revisions',
            'thumbnail',
            'author',
            'page-attributes'
        )
    );
    register_post_type( 'career_catalog', $args );
    
    // register taxonomy
    register_taxonomy('career_category', 'career_catalog', array('hierarchical' => true, 'label' => 'Category', 'query_var' => true, 'rewrite' => array( 'slug' => 'career-category' )));
}
add_action( 'init', 'career_init' );

<?php register_post_type( $post_type, $args ); ?>

<?php register_taxonomy( $taxonomy, $object_type, $args ); ?>


I hope you get an idea about wordpress tutorial for beginners(wordpress create custom post type programmatically).
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.