custom post type in wordpress

Custom post types are new post types you can create. A custom post type can be added to WordPress via the function like register_post_type() . This function allows you to define a new post type by its labels, supported features, availability and other specifics.

Please make sure 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 code sample for adding a custom post type:

Here we have created the custom post type as “cpt_team”. In which you can set your labels and accessibility.
Now we will add addition field by using add_meta_boxes.

So up to now we have created the UI for custom post type with additional field. now for storing the data of custom field like facebook link in our example in database for particular post than we need to put following code.

Now you can see in your WordPress admin panel that there there is “Our team” menu in left sidebar and after click on that you can add member and save the data related to member with custom field like Facebook link and you can also list the member data.

Leave a Reply

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