How to create custom post type manually in WordPress?

By Preetam Mallick

How to create custom post type manually in WordPress?


In this blog, we are going to show how to create custom post type manually in WordPress. Custom post type is like a page or you can say a component just like posts, pages, etc. Before we proceed, we need to have our functions.php of our main theme. If we use child theme then we should open functions.php in any code editor.

In the file functions.php, write the following code to create a custom post type. Let us assume that we have to create custom post type named as Testimonial.


The code

/*  custom post type function name */
function custom_post_type_function_name() {
            'labels' => array(
                 'name' => __('Testimonials'),
                 'singular_name' => __(Testimonial)
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'testimonial'),
            //if we need custom icon
            'menu_icon' => 'dashicons-format-chat',

//invoke the function
add_action('init', 'custom_post_type_function_name');

This is the basic method to create a new custom post manually. There are lots of options by which we can control our custom post type. We will discuss those options later on.

Please share if you like it.

Preetam Mallick Subscriber
Frontend Developer , Openweb Solutions

By profession I am a Frontend Developer at Openweb Solutions.

Frontend developer at Openweb Solutions
Posts created 14

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top