PHPMatters Help You Better Hosting Your PHP-based Sites
How to Add Custom Post Types for WordPress Websites

How to Add Custom Post Types for WordPress Websites

WordPress has developed into a leading content management system (CMS) although it initially started as a blogging platform. With one in every six websites running on WordPress, there are many features that the leading platform has in store to offer. One of the finest things that every WordPress website offers to its users is the categorization of content.

As the platform primarily only facilitates blogging, “Post” is the initial offering from WordPress. Apart from it, the user can update content on his website under many other categories such as Pages, Attachment, Revision and Navigation Menu. However, as the users seek for more options, WordPress has come up with a unique solution called custom post types. This tutorial is made to tell how to add custom post types.

What is Custom Post Types?

Custom Post TypesUsers can create a post and customize it as per their own preferences. The customized kind of post that can be created in a WordPress website is called as custom post type. The user can create as many customized posts in a WordPress site as he wants. The name of the customized post can be given as per the subject of the post or its basic theme. Portfolio, testimonials and reviews are some common examples of names given to a customized type of post in WordPress sites.

Benefits of Using Custom Post Types

There are several benefits of using a customized post type in a WordPress website. The primary advantage that users experience is the ease of categorization. He can easily categorize various contents belonging to a particular subject by creating a suitable post type. This makes it convenient for the webmasters to manage content as he can find, edit and delete posts quickly.

Custom Post Types Usage

Add Custom Post Types on WordPress

There are several methods to add an innovative type of post on a website that runs on WordPress. Out of the many, the most common and popularly known methods of creating a customized post are by using a plugin and by coding. Discussed here are both the methods, any of which can be followed to create a custom post on a WordPress site.

Plugin Installation

It is the easiest and the most preferred method of creating a custom post. It is followed by a thousand of developers, especially by the ones who are new in the field of website management. As WordPress supports the installation of a diverse range of tools, plugins are available for the creation of customized pages.

The first thing that is to be done in this process is finding a powerful and efficient plugin. As not all plugins are effective, one should always choose a popular plugin such as Custom Post Type UI. Now, an easy procedure should be followed for successfully installing this plugin. The detailed steps and image introductions can be found in this page.

Custom Post Type UI

  1. First of all, the folder containing the plugin data should be uploaded to the plugin directory presented in the WordPress site.
  2. Secondly, the plugin should be activated from the admin panel. The new menu can be added to the menu upon activation named the CPT UI.
  3. Thirdly, the “Add New” tab presented in the CPT UI menu should be clicked for the creation of custom post.

A new post type can be created, and then be named anything as per the choice of the administrator. It should be kept in mind that the name cannot exceed 20 characters.

Along with it, there are a couple of more things that are to be filled in. These include a Label, Singular Label and Description.

  1. The Label appears in the WordPress admin bar along with other labels such as pages and posts. Therefore, it can be written in the Plural form such as Movies, Recipes or Deals.
  2. Singular label assists the WordPress to highlight instructions and other user interface elements of the custom post.
  3. Lastly, the Description is used to describe the function or essence of the newly created post type.

Use Coding Stuff

In some cases, the method of plugin doesn’t work effectively. For example, when the plugin is deactivated from the admin panel, the custom pages lose its features, although the content is not lost from the directory. Similarly, sometimes the customization of one page may crash with another page. Therefore, coding is preferred for better performance of the post type.

A simple kind of customized category of the post can be created easily by following a couple of steps.

Firstly, the webmaster needs to visit the functions.php file of the WordPress theme. Secondly, he should insert the following code into this file after making some alterations.

custom post types code

In the above code, the product name is identified as “acme_product”, whereas the labels are Array, Products and Product. Without changing the code, the names can be modified to create a suitable custom post types on a WordPress website.