How to create custom post type in WordPress ?
There are several post types that are readily available to users or internally used by the WordPress installation by default :
- Post (Post Type: ‘post’)
- Page (Post Type: ‘page’)
- Attachment (Post Type: ‘attachment’)
- Revision (Post Type: ‘revision’)
- Navigation Menu (Post Type: ‘nav_menu_item’)
- Custom CSS (Post Type: ‘custom_css’)
- Changesets (Post Type: ‘customize_changeset’)
- User Data Request (Post Type: ‘user_request’ )
Custom Post Types
Custom post types are new post types you can create. A custom post type can be added to WordPress via the register_post_type() function. This function allows you to define a new post type by its labels, supported features, availability and other specifics.
Note that you must call register_post_type() before the admin_menu and after the after_setup_theme action hooks. A good hook to use is the init hook.
Here’s a basic example of adding a custom post type:
function create_post_type() { register_post_type( 'century_theme', array( 'labels' => array( 'name' => esc_html__( 'Century Themes', 'text-domain' ), 'singular_name' => esc_html__( 'Century Theme', 'text-domain' ) ), 'public' => true, 'has_archive' => true, ) ); } add_action( 'init', 'create_post_type' );
I was curious if you ever thought of changing the structure of your website? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or two images. Maybe you could space it out better?
Fantastic web site. Plenty of helpful information here. I am sending it to several friends ans also sharing in delicious. And of course, thank you for your sweat!
Amazing blog! Do you have any helpful hints for aspiring writers? I’m hoping to start my own website soon but I’m a little lost on everything. Would you recommend starting with a free platform like WordPress or go for a paid option? There are so many options out there that I’m completely confused .. Any ideas? Thanks a lot!
Wow! Thank you! I continually needed to write on my blog something like that. Can I implement a fragment of your post to my site?