When Custom Post Types was introduced in WordPress 3.0, it took WordPress to the whole new level. Instead of just a blogging platform, Custom Post Type gives more flexibility and extends WordPress to be a CMS. It helps to distinguish different types of content on your WordPress site – Post, Page, Attachment, Revision, and Navigation Menu – thus making it easier to manage your content.
For example, if you are a Web Design agency, you probably want to showcase your portfolio on your site. By creating a Portfolio custom post type, it’ll make it easier for you to manage your portfolio by differentiating it from other posts or pages. The CPT can be added to your WordPress site via
In this example, we’ll show you how to create a simple Portfolio custom post type. Of course, you can change the name to anything you want.
Simply put the following code in your
functions.php file or even better your functionality plugin:
There are lots of parameters can be accepted by the function to further customize your Custom Post Type. Please see the WordPress Codex for more info.
Here’s another example with lot more parameters:
Of course, you do not need to remember each and every single code. There are few tools available to generate the code for you. For example, take a look at the CPT Generator Toolwe introduced before.
We just showed you how to create a simple CPT. Of course, there are lots more you can do such as adding custom taxonomies, meta box and more.