HostOnNet Blog

How to create custom post type with specific template in WordPress

Looking for Linux Server Admin or WordPress Expert? We can help.

In WordPress, most commonly known content types are post and pages. We can use pages for creating pages like about us and posts types for blog posts. Today we can check how to create a custom post type in WordPress.

In this tutorial, I am creating a custom post ‘Portfolio’ using Custom Post Type UI Plugin

After install and activating the plugin, a menu option will appear named CPT UI. Go to CPT UI and Click add new Post type. Fill the fields with post slug, plural label, and singular label

Go to the bottom of the page and set Has Archive > True and click Save Post Type

Once this done, you can see the Portfolio menu item in the sidebar. Go to Portfolio > Add New > Add a post > Click Publish button.

View the post you created, the URL will be like

Templates for the custom post type

Now we can create a template for Archives and Single Entries. For creating the project archive, copy the contents of your theme’s archive.php file into archive-project.php template and then start modifying it to meet your needs.

Similarly, you can also create a custom template for your post type’s single entry. To do that you need to create single-project in your theme directory and copy the content of single.php

Add Custom post type to menu

Go to Appearence > Menus > Select your existing menu > Portfolio > Select All Portfolio and click add to menu button

About Sibi Antony

Bootstrap and Android LOVER. I've been creating things for the web for over 10 years, from the period of flash and table based layout web sites till mobile and tab friendly web sites.
Posted in Wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.