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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.