Creating a custom post type
The initial creation of a custom post type is extremely easy. It only requires a single function to be called from an action hook callback. Once in place, a lot of functionality immediately becomes available to editors, administrators, and site visitors.
Getting ready
You should have access to a WordPress development environment, either on your local computer or a remote server, where you will be able to load your new plugin files.
How to do it...
Follow these steps to create a new custom post type that will be used to store book reviews:
- Navigate to the WordPress
plugins
directory of your development installation. - Create a new directory called
ch4-book-reviews
. - Navigate to this directory and create a new text file called
ch4-book-reviews.php
. - Open the new file in a code editor and add an appropriate header at the top of the plugin file, naming the plugin
Chapter 4 - Book Reviews
. - Add the following line of code to register...