Create Custom Fields for Event Posts
Learn to work with dates in WordPress.
In this lesson, we will create a new post type for events taking place in the school. The event posts will be sorted according to the date the event takes place.
Create custom post type—event
Creating a custom post type has been covered in the Registering Custom Post Type lesson in detail. Navigate to the mu-plugins folder inside the wp-content folder. This folder has a school-custom-post-types.php
file where we registered the teacher and course post types. Following the same steps, we will register the event post type.
The school-custom-post-types.php
file has a function school_custom_post_types
which hooks onto the init
hook during the WordPress initialization. To create a custom post type, the first step is to define the attributes. Create an array of arguments called $eventArgs
as follows:
Get hands-on with 1400+ tech skills courses.