How to do it...

  1. Navigate to the WordPress plugin directory of your development installation.
  2. Create a new directory called ch4-book-reviews.
  3. Navigate to this directory and create a new text file called ch4-book-reviews.php.
  4. 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.
  5. Add the following line of code to register a function that will be executed during the initialization phase every time WordPress generates a page:
add_action( 'init', 'ch4_br_create_book_post_type' ); 
  1. Add the following code block to provide an implementation for the ch4_br_create_book_post_type function:
function ch4_br_create_book_post_type() {  register_post_type( 'book_reviews', ...

Get WordPress Plugin Development Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.