How to add custom post types in wordpress ?

What are custom post types in wordpress ?

Custom post types are a way to manage posts in an efficient way. Suppose your website have different products like cars, bikes, bicycles etc. You post about these but you want them to be arranged in different formats on front end. You may create different archive page and different single pages for these posts. These posts will appear as different menus in your admin panel. Looking for custom page templates? Visit custom page templates in wordpress.

Edit Post ‹ Make money online — WordPress

How to create custom post types in wordpress?

To create custom post types use code explained below in your fuctions.php :

basically the function is register_post_type( ‘custom_post_name_here’, $args );

in above example :

‘cars’ = custom post type name

‘name’ = name shown in admin menu

‘singular_name’ = name for single post

‘public’ = post is public or not ? ‘true’ for yes and ‘false’ for no
‘has_archive’ = to be shown in custom archive page ?  ‘true’ for yes and ‘false’ for no
‘exclude_from_search’ = to be excluded from searches on your website ? ‘true’ for yes and ‘false’ for no
‘supports’ = to add different features as they are in normal posts.
‘taxonomies’ = to add category and tags feature in newly created post types.
After placing above code in your website’s functions.php file go to admin panel. You will find a new menu item under name ‘cars’ or whatever you used in ‘name’ field.


Leave a Reply

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

%d bloggers like this: