Do you want to learn how to easily create custom post types and loops in WordPress?


Essentially, WordPress permits you to go beyond posts and pages by creating different content types for your site.

In this article, we’ll tell you the best way to create custom post types in WordPress. We’ll show you two methods and you can pick one that looks easier to you. You can make your own custom post types and call them anything you desire. For example, if you run a movie review website, then you would likely need to make a movie reviews post type. This post type can have other custom fields and even its own custom category structure. Other examples of post types are Portfolio, Testimonials, Properties, Ads, etc.

You will also watch that we are using custom taxonomies instead of categories or tags.

So, let’s take a look at how to create custom post types in WordPress for your own website.


Method 1. Creating a Custom Post Type – With Plugin

The simplest method to make a custom post in WordPress is by using a plugin. This method is suggested for beginners because it is safe and very simple.

The first thing you need to install and activate the Custom Post Type UI plugin. Upon activation, the plugin will add a new menu item in your WordPress administrator called CPT UI.

Now go to CPT UI  ➡️  Add Custom Post Type to create a new custom post type.

custom post type
Creating Custom Post type

First, you need to Give a slug for your custom post type. This slug will be used in the URL and in WordPress queries, so it can just contain letters and numbers and without space. Below that, you need to give the plural and singular text for your custom post type.

Next, you can see a link called “Populate additional labels based on chosen labels“. Doing so will fill in the rest of the labels at the bottom. Or you can fill those as per your choice.

After that, you will get the settings option. From here you can set up different attributes for your post type. Each option is shown there with a brief description.

Below the general settings, you will see the option to select which editing features this post type would support. Simply check the options that you want to be included.

custom post type code
Creating custom post type with code

Finally, click on the ‘Add Post Type’ button to save and make your custom post type. That’s all, you have successfully made your custom post type. You can feel free to begin adding content.

We will show you how to display your custom post type loop on your website.


Method 2. Creating a Custom Post Type Manually

The issue with using the plugin is that if you deactivate the plugin, your custom post types will disappear. Your custom post type will be unregistered and won’t be available from the administrator.

If you’re working on a client’s site and don’t want to install any other plugins, you can manually create your custom post type by adding the necessary code to your theme’s functions.php

First, we will show you a quick and fully effective example so you can understand how it functions. Take a look at this code:

 // Our custom post type function  

function custom_post_type_testimonial() {
        $labels = [
		"name" => __( "Testimonials" ),
		"singular_name" => __( "Testimonial"),

	$args = [
		"label" => __( "Testimonials" ),
		"labels" => $labels,
		"description" => "",
		"public" => true,
		"publicly_queryable" => true,
		"show_ui" => true,
		"show_in_rest" => true,
		"rest_base" => "",
		"rest_controller_class" => "WP_REST_Posts_Controller",
		"has_archive" => true,
		"show_in_menu" => true,
		"show_in_nav_menus" => true,
		"delete_with_user" => true,
		"exclude_from_search" => false,
		"capability_type" => "post",
		"map_meta_cap" => true,
		"hierarchical" => true,
		"rewrite" => [ "slug" => "testimonial_slug", "with_front" => true ],
		"query_var" => true,
		"menu_icon" => "dashicons-pressthis",
		"supports" => [ "title", "editor", "thumbnail", "comments", "author" ],
		"taxonomies" => [ "texonomy_slug_if_it_has" ],
		"show_in_graphql" => false,
       register_post_type( "testimonial_slug", $args );

add_action( 'init', 'custom_post_type_testimonial' );

What this function does is it registers a post type ‘Testimonials’ with an array of arguments. These arguments are our custom post-type options.
This array has two parts, the first part is labeled. The second part contains other arguments like has_archive, slug, taxonomies, and menu_icon enable block editor support. As you can see, we have added many more options to the custom post type with this code. It will add more features for the title, editor, thumbnail, comments, and more.

That’s all, you have successfully made your custom post type. You can feel free to begin adding content. We will show you how to display your custom post type loop on your website.

Check our other post to click here

About Sohan Yusuf

I’m an expert in WordPress including site-builders. I can code in HTML, CSS, PHP, JS & SQL. I helped more than 100 businesses to succeed online and improve their web presence. .

Leave a Comment

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