I recently switched this site to run on WordPress. For the amount of power WordPress provides, the underlying database is surprisingly simple, consisting of only 11 tables. Nevertheless, it took me a little while to understand the schema because everything is centered around posts and it was not obvious how other concepts such as pages and menus were supported.
After some research I learned that the term post comes from WordPress’ origin as a blogging platform. Since then WordPress has evolved into a powerful CMS, adding many more concepts. However the name post just stuck and has been overloaded to implement the newer concepts. Unfortunately, the database schema is not very useful in conveying these concepts. This is where a domain model would be more useful. The diagram below shows a domain model of WordPress, highlighting the domain concepts instead of implementation artifacts. Content is an abstract entity from which posts and other concrete entities are derived.
This model can be extended to show specific use cases for which you use WordPress. For example, a news site may use it to publish news articles, whereas an eCommerce site may use it to sell products. When designing such sites, it is useful to think in terms of domain entities like news and products instead of posts. Furthermore, you may want to explicitly show the attributes of these domain entities. For example, a news item belongs to a news section. This exercise will help you clearly define the requirements and how to map them to WordPress’ implementation. The domain model below shows a NewsItem as an extension of Content and belonging to a NewsSection.
The logical concepts shown above can now be translated to a WordPress implementation. For example, you can add a Custom Post Type (CPT) called news_type having a custom field called news_section. You can refer to the articles below to learn more about Domain-Driven Design and implementing your domain in WordPress:
- Domain-Driven Design
- When Do You Need a Custom Post Type or Taxonomy in WordPress
- How to Create Custom Post Types in WordPress
- WordPress Custom Fields 101