Creating forum and topic classes

We will start with the Forum class, as it is the most simple one of the two custom post types. So, create a file called class-wpwaf-model-forum.php inside the classes folder and define a blank class called WPWAF_Model_Forum, as shown in the following code:

    <?php       class WPWAF_Model_Forum {         public $post_type;         public function __construct() {                }       }     ?> 

Here, we have an instance variable for keeping the custom post type name. This class constructor is responsible for handling all the forum-related function initializations and definitions. The first task is to register a custom post type for a forum. Let's modify the constructor to add the necessary actions for the post type creation:

 class WPWAF_Model_Forum ...

Get Wordpress Web Application Development - Third 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.