Diving into WordPress Custom Post Types and Taxonomies

The ability to organize content is one of the most important functions of a content management system (CMS). It offers us a way to clearly define what belongs where. This impacts everyone from content creators accessing the back end to users navigating the public-facing website. And of course, search engines are also a big factor.

WordPress has an array of options for organizing content – but they might be easy to miss when you first install the software. Out-of-the-box, it comes with standalone pages, along with posts that can be further organized via categories and tags.

These items provide a great start and may be enough for a basic website. However, sites with a lot of different types of content can become messy when just relying on the default choices.

This is where a quick look under the hood unlocks the massively-useful WordPress custom post types and taxonomies. With them, you can create all-new and highly-specific ways to organize your content. Instead of trying to fit square pegs into round holes, you simply create new ones that are a perfect fit for your needs.

With that in mind, let’s look at a scenario where a custom post type or taxonomy can be helpful. We’ll also offer up some tips for making the most out of this feature.

Learning About Custom Post Types and Taxonomies

First, it’s important to have a cursory understanding of WordPress custom post types and taxonomies. You don’t need to be an expert, but it’s a good idea to know how they are set up and what options are available.

We have a short tutorial that will help you in getting started. In addition, it’s worth looking into the WordPress documentation regarding post types – and especially the register_post_type() and register_taxonomy() functions.

And, if you’re looking for a tool that makes creating custom post types and taxonomies a breeze, check out both Custom Post Type UI and Pods. Both of these free plugins greatly simplify the process. You can’t go wrong with either pick.

Lumping Everything into Posts Can Be Confusing

Standard WordPress posts are fine if you’re running a blog or news-oriented website. The ability to categorize and tag each post means you can easily separate press releases from opinion pieces.

But let’s consider a different scenario. What if you want to organize staff members by department? Forget about using standard pages, as they aren’t appropriate for this type of situation.

Posts might be a solution. You could create a “Staff” post category, then a child category for each department. From there, you can add a post for each staff member and assign them to their respective categories.

This all works, technically-speaking. But as your site fills up with content, visiting the WordPress Posts screen can become overwhelming.

A WordPress category listing.

Imagine being a content creator who needs to edit a post. Since some entries are blog posts, others are news items and still others are staff members, it’s difficult to find what you’re looking for. There are simply too many different types of content in the same place.

Then, displaying the staff members on the front end isn’t so simple. While you could create a custom category template, you may well have to create ones for each department to duplicate the desired formatting. The structure is also hard to keep track of. It’s even worse for another developer who comes in later on.

How a Custom Post Type + Taxonomy Can Help

This type of issue is exactly what custom post types and taxonomies exist to solve. In this case, creating a custom post type for “Staff” and a taxonomy for “Departments” will provide a separate area within WordPress exclusively for this content.

It’s a more intuitive experience all the way around. Now, those seeking to add or edit staff-related content need only click the entry within the WordPress menu. It’s much easier to find and just plain makes sense.

A staff listing.

On the front end, staff and department content get their own archives. This would allow designers to create custom templates that better reflect the content in this post type. You won’t have to settle for the same look and layout used for standard blog posts.

The URL structure is also more reflective of content as well. This not only looks better to the end-user but can benefit SEO. Speaking of which, a custom post type also allows for more targeted SEO customization when using a plugin such as Yoast SEO or All in One SEO Pack.

Whether you’re a content creator or a visitor, there are benefits all the way around. Any type of specialty content that doesn’t fit the mold of the traditional post or page is likely a good fit for this type of setup.

Considerations for Setting up Custom Post Types and Taxonomies

The above is just one scenario where a WordPress custom post type makes sense. But things aren’t always so clear-cut. You may have content that could benefit from its own post type and taxonomy, but may be unsure as to the best way to configure it.

Let’s look at a few important factors to consider before you dive into adding content:

Think About URL Structure

We won’t spend a ton of time on this, but how URLs are structured is important. Custom post types require a slug, which serves as the basis for how your posts are organized.

You’ll want to choose a slug that makes sense for your content. Taking our Staff post type as an example, the URL for its archive index might be:

https://www.yourgreatsite.com/staff/

In this case, “staff” is the slug for our post type. Perhaps not the most exciting name, but certainly logical.

Also beware that existing content on your website may already be using a particular slug. Therefore, you may have to change things around in order to accommodate this new post type.

Do Posts or Taxonomies Require Parent/Child Relationships?

There’s a little secret to WordPress custom post types and taxonomies. Whatever you name them, they all function essentially the same as standard pages, posts, categories, and tags. And you can configure them to work within these parameters.

Pages are standalone pieces of content that are hierarchical – meaning they can have parent/child relationships. While a custom post type can be set up to utilize page-like functionality, it’s not all that common. Using the default Pages post type that comes with WordPress often works just as well.

Posts act as a collection of content within WordPress. Ideally, all posts in a custom post type are related in some way. They might be blog posts, staff member profiles, or even products that we’re selling. They are not hierarchical.

Categories and tags are two different ways to further organize post content. And each custom taxonomy we create contains properties specific to one or the other.

The main difference between the two is a hierarchy. If a taxonomy is hierarchical (enabling parent/child relationships), then it behaves like a category. If there’s no hierarchy, it behaves like a tag.

In our example, the “Departments” custom taxonomy is hierarchical. This allows us to:

  • Assign individual staff members to one or more departments (Executive Leadership, Human Resources, etc.);
  • Add more layers to organize content, such as sub-departments, which act like child categories (Executive Leadership > Finance, Human Resources > Benefits);
  • Display content based on departments and sub-departments;

A custom taxonomy screen for Departments.

On the other hand, not all content needs to be organized with a parent/child hierarchy. This where tags come in handy. And you can set up a custom taxonomy to behave in the same way. Content is grouped on a singular level.

When deciding on how you want to build out custom post types and taxonomies, determine your needs with regards to hierarchy. You can make changes after-the-fact, but it’s much easier to start on the appropriate path.

Create as Many Taxonomies as You Need

Custom taxonomies give you an easy way to organize content. And there’s no real limit to how many of them you can create to go along with your post types. This can be especially handy when you need to filter posts based on more than one criterion.

For example, let’s say that our Staff post type covers employees in several different office locations. By creating taxonomies for both Departments and Offices, we could easily filter posts based on a combination of the two.

A locations taxonomy listing.

If we need to see only Human Resources employees from the Scranton office, we can. Likewise, if we wanted to list all the Executive Leadership in the New York City and Stamford offices, a query can be built to do so.

Taxonomies provide a means to sort data in a way that would otherwise be incredibly difficult.

Go Further with Custom Fields

There are instances where the content you want to place in your custom post type goes beyond what WordPress offers in a default installation.

For instance, a staff member profile might include information such as the employee’s title and email address. While you could manually add these into each post’s main content area, it could lead to some inconsistencies in formatting.

Adding custom fields for both “title” and “email” would solve that problem. With them, data can be queried separately and allow for a more consistent way to add and display content.

WordPress custom fields for staff member profiles.

Customize Your WordPress Content

We spend so much of our time customizing the look and layout of our website projects. But it’s also important to pay close attention to how content is organized as well.

That’s what custom post types and taxonomies are there to do. They allow us to put related content together according to need. That, in turn, makes it easier to create, edit, and display.

We hope this guide has helped you better understand when it makes sense to implement these features and how to best use them. It’s the kind of knowledge that can help you deliver a website that is well organized, SEO-friendly, and easier to navigate.

The post Diving into WordPress Custom Post Types and Taxonomies appeared first on Speckyboy Design Magazine.