Content Modelling: The Most Overlooked Route To A Successful WordPress Site

FavoriteLoadingAdd to favorites

Too many WordPress site owners force round pegs into square holes by building their sites on the built-in content model of posts, pages, categories and tags, creating major long-term headaches and constraints for the design and management of the site.

Taking a little time up front in the design process, or even overhauling a current site, to create a content model that genuinely reflects the type and range of content you are publishing will dramatically increase your site’s flexibility and provide a superior experience for both you, the site owner, and your visitors.

In this article, we’ll take a look at how simple it is to model your site’s content, when to use the built-in model and when to extend it with custom post types and taxonomies.

Handdrawn diagram of the built-in WordPress content model
Modelling content is one of the most overlooked tasks in creating an effective, flexible and stable site

It doesn’t take much for your WordPress site to move beyond the capabilities of the built-in content model of posts, pages, categories and tags.

Often we extend the model without even realizing it as we add plugins that create new content types such as products, orders and events. A natural process that we don’t think twice about.

When it comes to our own content, though, it seems to be a different matter. We’ve all worked on (or indeed built over time) sites where content gets shoehorned into posts and pages, and categories and tags become identifiers rather than categorizers.

This is often a slow, somewhat insidious process, driven by quick fixes but the result is always the same: an unwieldy mess of a site that is as inflexible as it is difficult to manage.

The answer is to properly model your content.

Of course, it takes a little time but the time spent now will be saved many times over in the lifespan of your site.

Why You Need A Content Model

Other than being best practice for the creation of a site, the reasons for developing a content model fall into 3 broad categories:

Design

Without a content model, designing a new site is incredibly difficult. A content model will ensure that you have a design for each type of content on your site (do your tutorials need to look different to your reviews which may look different to your news items). You may also want your archives to behave differently according to the type of content being displayed.

The relationships too can help us. If we can see that events have one or more experts then we know that we need to cater for this – listing experts – when designing the layout of the event template.

A full content model will also ensure that your designers are fully aware of each of the attributes of a content type and will ensure that these are catered for in the design and layout of the various templates.

Content Creation

A content model tells us not only about the types and their relationships (if any) to each other but also about the individual attributes of the types. This enables us to ensure that all required data is captured when content is being created.

Development

If you have a content type that has specific functionality, then clearly you need to add that to your model.

For example, on this blog, we have a Review content type that will automatically calculate an average rating for an item from its individual criteria ratings. This is, of course, a very simple example and you need to look at the various e-commerce plugins to see that functionality can get incredibly sophisticated both on the front and back ends.

Management

A fully-defined content model can also have a massive positive impact on the management of your site:

  • Easy access to content creation from dedicated admin menu options
  • Ability to import and export specific types (i.e. just events, just experts)
  • Create distinct workflow for a content type
  • Remove certain types of content from search results

What Is A Content Model?

A content model is a representation of the various types of content your site contains and any relationships between them.

This is not a physical description – at this stage, we are not really interested in how to implement this in WordPress, we just want to be able to identify the various content types and their relationships.

For example, here’s the content model for a site I was involved with recently that organized events for those looking to renovate or build to “speed date” professionals such as architects, builders, landscape and interior designers:

3 entity content model
Simple example of a content model with a many-to-many relationship

As you can see, there’s three entities, event, expert and expertise. There are two relationships: a many-to-many relationship exists between experts and events (events can have many experts and experts can attend many events); and, experts and expertise have a one-to-many relationship (an expert can have multiple expertise).

For the moment we won’t concern ourselves with how the relationships are managed we just need to be aware that they exist.

Creating Your Content Model

It’s important in the initial draft to ensure that you capture all the different types of content and any relationships so don’t worry too much about whether it really is a new content type or not – you can fix it up later. Just keep these main points in mind:

  • Put to one side any thoughts about how you’ll implement your model in WordPress. At the moment you are in “blue sky” mode and not concerned with the physical implementation.
  • You don’t need to worry about how relationships between content types are maintained simply that they exist
  • When you have the content types, add their attributes (fields). Try and be as comprehensive as you can as it may make implementation a lot easier if you know exactly what the attributes are before you start.
  • Keep the built-in types (posts and pages) for news type content. If you don’t have a need then don’t use them.

How To Rationalize Your Content Types

When you have completed your first draft, you need to review the content types you have created to ensure that each does indeed need to be its own type. A “yes” to one or more of the following questions means that needs to be a unique type:

  1. Does the content type need its own layout or design?
  2. Does the content type have unique functionality (workflow, permissions, handling)?
  3. Does the content type have unique additional attributes (custom fields)?

Translating Your Model To WordPress

Now the fun bit!

Before we start, it is important to note that WordPress is firmly built on the blog model (posts, categories, categories, tags), supplemented with pages, that cannot be extended without the use of custom code or plugins, unlike many more-recent content management systems that have content modelling as part of their native offering.

We are, in effect then, extending the WordPress model rather than building a new model. Our content types become custom post types; attributes beyond those provided by a standard post become custom fields; and custom categories (and tags) become custom taxonomies.

To allow our experts to have multiple expertise we can simply use tags (non-hierarchical taxonomy as the terms are not structured).

Where we do need to get a little creative is in modelling those relationships. One-to-one and one-to-many relationships are supported either by parent id attribute of a post (actually used by pages) or through the use of a taxonomy (categories or tags) but there is no built-in support for many-to-many relationships.

Whilst you could resort to a custom table, you’ll potentially have to resort to a lot of heavy lifting to generate the control for the user interface to manage the relationships. My preference is to try and stick within the WordPress model and use a custom taxonomy. It might not be as tightly coupled as we’d like but there’s no need to worry about interfaces to manage the relationship.

For example, our events and experts have a many-to-many relationship: an event will involve many experts and an expert can attend many events. The design requirements are to be able to list the experts for an event (we might also want to list the events attended by an expert).

We can achieve this in WordPress using an event tag on both events and experts. So, if event 1 is tagged event1 and event 2 is tagged event2 then adding the event1 tag to expert1 and expert2 will create that relationship between the experts and the event. Adding additional tags to the experts (e.g. event2) create connections to other events.

When the template for an event is created, the list of attending experts can now be generated by finding all the experts who have been tagged with the events own event tag.

Get To Know The WordPress Template Hierarchy

The WordPress template hierarchy is not part of the content model but a change in your content model will have an impact on the way that WordPress searches for templates when trying to display content.

If WordPress determines that the request is for a custom post type then it will prioritize templates that specific to that custom post type. Simply adding these templates to your theme will ensure that they will be used instead of the default templates:

  • archive-{custom post type name}.php e.g. archive-event.php to display a list of events
  • taxonomy-{custom taxonomy name}-{term name}.php e.g. taxonomy-eventexpert-event1.php to display a list of experts tagged with event1
  • single-{custom post type name}.php e.g. single-event.php to display an individual event
Partial hierarchy diagram linked to full iagram
Explore the WordPress Template Hierarchy

Plugins To Help Implement Your Model

Whilst you can build your model using code (generatewp.com can be a great help) it is far easier to use a plugin that provides all the functionality you’ll need, wrapped in an user interface.

Whilst there are many to choose from, here’s 3 that will meet virtually all your needs. There’s also a bonus plugin that is invaluable if your initial content load is from CSV formatted files.

CustomPress

CustomPress logo
WPMU DEV’s own content modelling tool – perfect for light to medium weight modelling

Not surprisingly, I tend to use WPMU DEV’s own CustomPress plugin. Provides the ability to create custom post types, custom fields (and allows you to select on which custom post types the fields should appear) and custom taxonomies quickly and easily.

Also provides shortcodes and functions for outputting the custom field content although it does generate some fairly quirky field names.

An easy to use to plugin and a good choice for light to medium weight content modelling.

Find out more about CustomPress.

Pods – A Content Development Framework

Pods logo
A must-have for the power-crazed heavyweight content modeller

A free plugin that goes well beyond the features of most custom content plugins.

As well as providing the standard custom post type, custom taxonomy and custom field creation it also allows the creation of custom settings panels and advanced custom post types that generate their own database tables.

Pods also has a range of custom field types including file upload and a relationship handler that will handle the many-to-many relationships we talked about earlier.

And if that is not enough, then Pods will also allow you to extend users, comments and media and has a swag of add-ons to provide even more functionality.

A must-have for the power-crazed, heavyweight content modeller.

Find out more about Pods.

Types

Types logo
Capable modelling tool that forms part of a powerful toolset

A plugin that comes standalone for free or part of a premium package it sits somewhere between CustomPress and Pods.

Custom post type, taxonomy and field creation that is extended to users, the list of custom field types is impressive and also includes relationship management.

Types strength is probably strongest when used as part of the package that provides Views for output of custom content, CRED for the building of front-end editing capability and Access for permission-based access to content.

Find out more about Types.

WP Ultimate CSV Importer

Advanced CSV importer logo
Can be a real time saver if your initial population of content is from CSV files.

Not a modelling tool as such but invaluable if you get the initial data for your site in a spreadsheet.

Once your custom post types have been created, this plugin will allow you create new content by importing from a CSV file, including handling the populating of custom fields.

The premium version will allow the population of custom taxonomies.

Find out more about WP Ultimate CSV Importer

Further Reading

If this article has whet your appetite about content modelling then here’s a short list of further reading:

Content Modelling :  A Master Skill (A List Apart) 

What Is Content Modelling? (Cleve Gibbon)

Content Modelling For WordPress (series by Stephanie Leary)

Reading is good, of course, but ultimately the best way to get good at modelling is practice!

Do you use content modelling as part of your development methodology? Do you have a favorite WordPress plugin for implementing your models? 

Visit original source.



Categories: Tutorials

Subscribe

Subscribe to this Journal

Subscribe to our Saturday morning digest of each week's new content. ITS FREE!

Email address