How To Create Custom Post Types in WordPress (Without a Plugin)

WordPress gives you the ability to create custom post types. Want a different type of page than just post, page, or media? Create your own custom post type by following these steps:

Custom post types give your WordPress Hosting new capabilities for expression.

How To Generate a Custom Post Type Without A Plugin

For this tutorial, you will use the Post Type Generator website to generate your own custom code so you can add it to your site. In order to register your custom post type, you could use the sample code provided, but you should update these options to your specific needs.

  1. Go to the Post Type Generator
  2. Fill in the fields for your custom options
  3. Click Update Code
  4. Create a file on your computer that ends with a .php extension (for example, custom-post-type.php)
  5. Add the WordPress plugin file header to the very top of the code1
  6. Put the PHP file in its own folder on your computer
  7. Compress the entire folder (for example custom-post-folder.zip)
  8. Install the zip file on your WordPress site

Now your custom post type is available as a custom plugin. All you need to do is activate it.

Why You Should Use Custom Post Types

All the content you add to WordPress (Posts, Pages, and Media) are all merely different “post types.” This means you can create your own post types. A different post type lets you organize your content more efficiently. For example if you have a blog and you want to start adding recipes to your site, you don’t need to have both blog posts and recipes all listed under “Posts.” You can keep your blog posts under “Posts” and have recipes created under a new “Recipes” post type. Also, if you desire, this lets you customize the page templates for recipes so they display differently than posts.

You can always create custom post types with plugins. (There are plenty of plugins out there that can do this.) But adding more plugins to your site increases your site’s overhead and can leave security doors open to hackers. It’s always better to do your own custom coding. The steps you’ve taken in this article may have required a little more work, but you’ll be glad you have your own custom code.

Footnotes:

1
This is information about your plugin that will allow you to activate it in the WordPress admin area.

Leave a Reply