How to use register post type in wordpress

register_post_type should only  be invoked through the ‘init’ action. it wont work at all if called before init action.

let me explain in brief whats the use of that and how to use that in any plugin. suppose i have so many pages/post in wordpress and in that my sliders post/pages also i have added in that page.

in short, i want to create a new page same as like wordpress’s default post/pages page than using below code i can create same page with its functionality in wordpress that one is called register post type functionality in wordpress.

have a look in below code and try in your code than you will get clear idea.

if you have created any plugin than add this above code in index.php of your plugin folder. and checked once what happen for adding the above code.

the above code will give you the new register post of slider so in that all your slider post you can see, no need to search that one in post/pages.

this is a very easy and nice functionality of wordpress. i m also using this above code.  in one site i have so many post and slider’s post i have added in posts and later for searching only slider’s post i m very confused for searching slider’s post i decided two build new page same as like posts functionality and i got above code and i have used this above code and my problem is solved.

once try to get clear idea what the use of register_post_type in wordpress.