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 http://example.com/portfolio/your-post.
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