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.

Read Also:  Create First WordPress Plugin Step by Step for Beginners

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  How to Fix uploaded file exceeds the upload_max_filesize Error in php.ini WordPress?
  2. Read Also:  How to get featured image of a product in woocommerce
  3. Read Also:  Woocommerce get price in custom loop
  4. Read Also:  get_post_meta in WordPress Example
  5. Read Also:  Custom Pagination Using WooCommerce REST API
  6. Read Also:  Simple Create WordPress Plugin Tutorial
  7. Read Also:  How To Get Last Insert Id In wpdb WordPress?
  8. Read Also:  Check WordPress Plugin Dependencies
  9. Read Also:  000webhost 2020 : free web hosting with cpanel PHP and MySQL
  10. Read Also:  Check WordPress Plugin Dependencies
CLOSEX