Select Page

There are two ways of creating custom post types into WordPress: First is using a “plugin” but if you want to keep your WordPress website liteweight then adding a snippet of code to your child theme’s function.php would be the best practices.

Note: If you don’t want to keep your hands thirty then simple use custom post type maker plugin to generate your preferred custom post type. Also, using a ‘child theme’ is a must if you do the manual way of adding custom post type in your function.php otherwise your code would not be “safe”, it will be vanish once you update your Parent WordPress theme.

Now, Let’s begin to create a custom post type!

But first let me ask you a question, would you like to create a new one or just overwrite the existing default custom post type available on your WordPress theme? If the answer is both then no worries, I will reveal the solutions.


Register Your Own Custom Post Type :

Let say you want additional custom post type named “Calculators”? Your magic savior is to use the function called register_post_type( string $post_type, array|string $args = array() ) . That will allow you to register a new section on WordPress dashboard. Take note string $post_type  can be anything, you can use whatever name you want!

Here’s the example syntax:

function my_custom_section() {
register_post_type( 'calculators',
'labels' => array(
'name' => __( 'Calculators', 'divi' ), 
'add_new' => __( 'Add New', 'divi' ),
'singular_name' => __( 'Calculator', 'divi' ), 
    'has_archive'  => true,
    'hierarchical' => true,
    'menu_icon'    => 'dashicons-editor-table', 
    'public'       => true,
    'rewrite'      => array( 'slug' => 'calculators', 'with_front' => false ),
   'supports'     => array(),
add_action( 'init', 'my_custom_section' );


Overwriting default custom post type available in your WordPress theme

Now, what if there’s a default custom post type in your WordPress theme that is not useful and you just want to update the name? Example “the default Projects custom post type available in Divi“?  Well, all you need to do is get the exact registered post type of that section. When you view to all section and view each projects, you will see that the reserve name is “project

how to change the default custom post type in wordpress

Make sure you note the reserve name and assign it to $post_type.

overwriting default wordpress custom post type

Rule of thumb: Once you activate your child theme and add the code to your child theme’s function.php, it will overpower the parent theme.

If you want to add more labels and arrays then here’s the complete list: Visit the WordPress register custom post type documentation for more guide about the syntax. 
full list of custom post types labels and array