How to add custom post types without the CPT plugin in WordPress?

How to add custom post types without the CPT plugin in WordPress?

Step 1: Create a Child Theme (Optional but Recommended)

Before modifying the functions.php file, it's a good practice to create a child theme to ensure your changes are not lost when the parent theme is updated. If you're not familiar with creating a child theme, you can find instructions in the WordPress Child Themes documentation.

Step 2: Visit GenerateWP

Visit GenerateWP website

Go to the GenerateWP Custom Post Type Generator.

Step 3: Fill Out the Form

You'll see a form with multiple fields. Fill in the fields according to the custom post type you want to create. Here’s an explanation of some key fields:

  • Post Type Name: Enter the name for your custom post type (e.g., book).
  • Singular Name: Enter the singular name (e.g., Book).
  • Plural Name: Enter the plural name (e.g., Books).
  • Slug: This is the URL-friendly version of the post type name (e.g., book).

Labels Section

Fill in the labels for the custom post type. This includes names like Add New, Edit, View, etc. These labels will be used in the WordPress admin.

Settings Section

Configure the settings for the post type:

  • Public: Check this box if you want the post type to be publicly accessible.
  • Show UI: Check this box to show the custom post type in the admin UI.
  • Has Archive: Check this if you want to enable archiving for this post type.
  • Supports: Choose the features you want this post type to support.


Step 4: Click on the Generate Code Button

The Code will be generated according to your given fields now you have to copy this code as it is and paste it into a file at the end of 'functions.php'

  1. Open your WordPress theme directory.
  2. Find and open the functions.php file.
  3. Paste the generated code at the end of the functions.php file.
  4. Save the file.

Final Steps

After adding the code to your theme or plugin:

  1. Flush Rewrite Rules: Visit the Settings > Permalinks page in the WordPress admin to flush the rewrite rules.
  2. Verify: Check the WordPress admin menu to see if your custom post type appears. Create a new post of your custom type to ensure everything is working as expected.

By following these steps, you can create custom post types without using a plugin like CPT UI, using the GenerateWP tool to simplify the process.


If you liked this article, please like, follow, and share!



要查看或添加评论,请登录

Muhammd Farhan Yaqoob的更多文章

社区洞察

其他会员也浏览了