How to create custom post type in WordPress

| Last Updated: | In: 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.

Tags: , , , , , ,


About: Prem Tiwari

Prem Tiwari is the founder of freewebmentor.com and is a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby.


You may also like:

Follow us!

Get Free Access of 380+ Scripts

Don't worry you'll not be spammed!

Featured eBook

WordPress Security Guide

Free Guide: Learn how to implement security guideline in your WordPress site...

DOWNLOAD

Pincode Finder

pincode-finder tool

Online Pincode Finder

Best tool to locate post Office address and pincodes of all india...

SEARCH NOW
Copyright © 2013-2017