How to make a custom post type in wordpress ?

Developerking
1 min readJan 13, 2023

To create a custom post type in WordPress, you can use the register_post_type() function. Here are the steps to create a custom post type:

  1. Create a new plugin or add the code to your theme’s functions.php file.
  2. Use the register_post_type() function to create a new custom post type.
function create_custom_post_type() {
register_post_type( 'custom_post_type',
array(
'labels' => array(
'name' => __( 'Custom Post Type' ),
'singular_name' => __( 'Custom Post Type' )
),
'public' => true,
'has_archive' => true,
)
);
}
add_action( 'init', 'create_custom_post_type' );

3. Replace ‘custom_post_type’ in the code with the desired name for your custom post type.

4. Replace ‘Custom Post Type’ in the ‘labels’ array with the desired name for your custom post type in the WordPress admin.

5. You can also add custom taxonomies, custom fields, etc.

6. Save the changes and activate the plugin or refresh your site.

The custom post type will now be available in the WordPress admin under the “Posts” menu. It is recommended to test the changes on a development environment before pushing it to live site and also take a backup of your site before making any changes.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Developerking
Developerking

Written by Developerking

We are creating the world's largest community of developers & Share knowledgeable contents , So Stay Tuned & Connect with us !! Become a Dev King Member.

No responses yet

Write a response