How To Create Custom Post Types in WordPress (With & Without Plugin)
As we all know WordPress is very incredible CMS no matter what type of Site you'll be making, it's perfect for almost every type of Website; From eCommerce to Personal Blogs. WordPress is not only full-free but fully Open-Source too, also it does comes with Tons of Free & Paid Themes as well as Plugins to make both the Functions & Aesthetics top level.
The Labels will be used everywhere in the WordPress interface while managing the content In that particular Custom post type.
Wordpress has many different types of features that support every type of use & requirements of their users, and as we mentioned earlier it's 100% open-source, hence you can customize almost anything either manually or using a Plugin.
So, moving straight forward to our Topic...
By default, Wordpress has two types of Post system; either Page or a Post, so if you want to add a Custom Different type of Post-Type in WordPress then you have to add a Custom Post-type in your WordPress site. It's easy, you just have to Install a Plugin, Do some settings and you're all set, but in case if you want to do it manually, then this guide will surely helping you out in this.
By continuing reading this Article about Custom Post-type in WordPress, you'll learn 2 Ways to Add a Custom Post-type on your WordPress site; One with Manual Code, and the other With a Plugin which we'll discuss later in this post.
But before jumping to the actual tutorial, you first have to know what is Custom Post-type in WordPress, and how will Actually help you in managing your WordPress site.
What is Custom Post-Type in WordPress
Let's say you have a Game Listing Website where you list Games with their Prices, Launch Status, and some more info about the game. So for this, you can create a Custom Post-Type called "Game-Listings" or whatever you want it to be called, this way it'll be a lot easier to manage your Website Content between different type of Website Contents such as Game Listing, Post, News Articles, and Website Pages and so on.
Method 1: Creating a Custom Post Type - The Easy Way
There are a variety of Plugins that are available on WordPress for setting up your own Custom Post-Type, both Free & Paid. So here's the list of Best Wordpress Plugins for Custom Post-Types.
Custom Post Type UI |
- Let's you create Custom Post-Types and Custom Taxonomies
- Let's attach built-in and custom taxonomies to post types.
- Comes with advanced labeling
- Does not handle the display of your new post types and taxonomies. This, you have to do yourself.
Custom Post Type UI is one of the most popular WordPress Plugin Right now for Custom Post-Types as it gives you great features and options all for free. After Installing, the plugin lets you create custom post types on your site and also lets you edit the pre-existing ones. You get a Nice Dashboard here for configuring every type of Feature and option that this plugin provides you.
Its more interesting features include one where you could Import a custom post that you already have on another site, and export them from your site too. Although the only feature that is missing here is that it doesn't manage the Displaying of your Custom Post Types, so you have to do it Yourself.
WCK Custom Post Types and Custom Fields Creator |
- Have features for what they have meant for custom post types, taxonomies, and fields all for free
- Supports WYSIWYG editor, upload, text, text area, select, checkbox, radio, number, HTML, time-picker, phone, currency select, color picker, heading.
- Lets you connect the post types with the custom taxonomies.
With the basic Free Version of WCK, you get to Create Custom Post types with Custom taxonomies, meta, and fields. In WCK it's easy to add a new custom post type, to do this just open WCK in your dashboard menu and click on Post Type Creator, there you'll only have to configure a few options to get your Custom Post Type ready, and once ready it'll start appearing in the menu from where you can configure it further, and adjust it as per your needs.
For more Advanced Functions & Options such as option pages and extra custom field types, you must upgrade to the premium version, starting from $49.
Now here's How To Create Custom Post Type in WordPress using Custom Post Type UI Plugin:
The First thing you need to do is install and activate the Plugin, Upon activation, the plugin will add a New Menu item in your WordPress sidebar Menu called CPT UI.
Now head toward CPT UI » Add News to create a Custom Post type
Creating custom post type in Wordpress with Pugin |
You'll be required to type in a slug for your custom post type. This slug will be used in the URLs so keep the letter lowercase.
Below that, you have to Provide the Plural & Singular Names for your Custom post type.
Next, you can also optionally choose ‘Populate additional labels based on chosen labels’ which will fill in the rest of the label fields down below.
Now, Scroll down to the 'Additional Label' Tab to Provide a Description for your post type, you can also change the labels here.
Creating custom post type in Wordpress with Pugin |
Continuing further shows you the Post Type settings where you can set up the attributes for your Post Types. In general, it's recommended not to make a post type hierarchical like pages or reverse chronological like posts.
and, finally comes the General Settings for your WordPress Custom Post Types, here you'll see some more options which you can check or uncheck according to your choice.
Once it feels Good to go, finally press the Add Post Type button to save & establish your Custom WordPress Post Type
Once pressed, a Custom Post Type is successfully configured on your WordPress site, now you can move on and start adding content towards them.
Method 2: Creating a Custom Post Type in WordPress Without Plugin
Once the Plugin which you used to set up the Custom post type Deactivate by Instance or Mistake, everything will be gone. Any data you have in those Custom post types will still be there, but it will not be accessible from Admin Area, and your custom Post Type will not be registered until and unless you re-install the Plugin. So, you should go with Creating a Custom Post Yourself Manually Without Using Plugin.
You can add a custom post type in your WordPress site without using any plugin, then it can be done by adding the required lines of code to your functions.php file inside your theme folder.
Not to take any credit, we would like to mention that thecode provided to you here is taken from WPBeginner. Every right for the code belongs to them and we do not hold any right over the code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | /* * Creating a function to create our CPT */ function custom_post_type() { // Set UI labels for Custom Post Type $labels = array ( 'name' => _x( 'Movies' , 'Post Type General Name' , 'twentytwenty' ), 'singular_name' => _x( 'Movie' , 'Post Type Singular Name' , 'twentytwenty' ), 'menu_name' => __( 'Movies' , 'twentytwenty' ), 'parent_item_colon' => __( 'Parent Movie' , 'twentytwenty' ), 'all_items' => __( 'All Movies' , 'twentytwenty' ), 'view_item' => __( 'View Movie' , 'twentytwenty' ), 'add_new_item' => __( 'Add New Movie' , 'twentytwenty' ), 'add_new' => __( 'Add New' , 'twentytwenty' ), 'edit_item' => __( 'Edit Movie' , 'twentytwenty' ), 'update_item' => __( 'Update Movie' , 'twentytwenty' ), 'search_items' => __( 'Search Movie' , 'twentytwenty' ), 'not_found' => __( 'Not Found' , 'twentytwenty' ), 'not_found_in_trash' => __( 'Not found in Trash' , 'twentytwenty' ), ); // Set other options for Custom Post Type $args = array ( 'label' => __( 'movies' , 'twentytwenty' ), 'description' => __( 'Movie news and reviews' , 'twentytwenty' ), 'labels' => $labels , // Features this CPT supports in Post Editor 'supports' => array ( 'title' , 'editor' , 'excerpt' , 'author' , 'thumbnail' , 'comments' , 'revisions' , 'custom-fields' , ), // You can associate this CPT with a taxonomy or custom taxonomy. 'taxonomies' => array ( 'genres' ), /* A hierarchical CPT is like Pages and can have * Parent and child items. A non-hierarchical CPT * is like Posts. */ 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'post' , 'show_in_rest' => true, ); // Registering your Custom Post Type register_post_type( 'movies' , $args ); } /* Hook into the 'init' action so that the function * Containing our post type registration is not * unnecessarily executed. */ add_action( 'init' , 'custom_post_type' , 0 ); |
The code given above will create a New custom Post type in Wordpress with some adjustable features and options that you can configure from the code given above. This code will allow your Custom post type to use features like revisions, featured image, custom fields, public visibility, has an archive, slug, and Block editor Support.
Comments
Post a Comment