Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

How to Create a Custom Post Type in WordPress

How to Create a Custom Post Type in WordPress

How to Create a Custom Post Type in WordPress programmatically, If you are a word press developer some time you need to do some thing different, you can’t do every thing in elementor or WP Bakery, word press comes with custom post so first thing is know that What is WordPress custom post ?

How to Create a Custom Post Type

Custom Post Type in WordPress

A custom post type (also known as CPT) in WordPress is a feature that allows users to define their own content types beyond the default posts and pages. There are some default post type are :

  1. Post
  2. Page
  3. Attachment
  4. Revision
  5. Nav Menu

Some times we need to create a our own custom post. We can create a custom post in 2 way

  1. Using Plugin
  2. Custom Code

How to Create a Custom Post Type in WordPress using Plugins

If you don’t want to code, still you can create word press custom post using plugins like CPT UI and you want create custom filed then use Advanced custom field plugin.

How to Create a Custom Post Type in WordPress using Custom PHP Code

If you want to create a custom post type in wordpress programmatically then you need add the php code give below to your theme’s functions.php file

// Our custom post type function
function bestDeal_custom_post_type() {

register_post_type( 'product',
// CPT Options
array(
'labels' => array(
'name' => __( 'Best Deals' ),
'singular_name' => __( 'Best Deal' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'best_deal'),
'show_in_rest' => true,

)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'bestDeal_custom_post_type' );

Reading code’s comment you can understand the code easily. still you have ant query then let me know through your comments, I will try to answer your queries.

If you have and query or suggestion or need assistance  then please contact me, I will reply to fix your problem, if you like our content then you can subscribe to our Youtube channel. If you want to hire me then reach us at our Fiverr.