Free Classified Site - Bedpage

How to create custom post type in WordPress

Prem Tiwari - - WordPress, WordPress Beginners

Are you want to create a custom post type in your WordPress site, then this tutorial is for you. In this tutorial, i am going to explain how to create custom post type in WordPress.

This will help you create custom post types. WordPress have some default post types like post and page and WordPress also give you privileges to create unlimited post types as per your requirement. Bellow are the simple steps to create and use custom post types in your WordPress sites.

WordPress Custom Post Types

Default Post Types

Below are the lists of default post types which come up with default WordPress installation:

1) Post (Post Type: ‘post’)
2) Page (Post Type: ‘page’)
3) Attachment (Post Type: ‘attachment’)
4) Revision (Post Type: ‘revision’)
5) Navigation Menu (Post Type: ‘nav_menu_item’)
6) Custom CSS (Post Type: ‘custom_css’)
7) Changesets (Post Type: ‘customize_changeset’)

How to Create a Custom Post Type

Just assume you have a school website and you want to create a custom post type named subjects. Now open your functions.php file from your current activated theme and copy paste below snippet. This will registered a custom post type.

How to Add Custom Post Types in Main Query

If you have created a custom post type, it does not mean that it will automatically added in the main query of WordPress you have to add your custom post type in WordPress main query.
Below is the example of how to add your custom post type in main query. Copy paste

How to Add Custom Post Types to Main RSS Feed

Copy paste below code in functions.php file of your current activated theme. Below snippet will add your custom post type in main RSS feed.

About: Prem Tiwari

Prem Tiwari is the founder of and also a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies.

Tags: , , , , , ,

Recommended Tutorials

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.