What are Custom Post Types? (and why are they useful)

What are Custom Post Types?

In this article, I discuss what Custom Post Types are, and how they can help. The aim is to inspire you to use them to improve your WordPress website.

WordPress, like any subject, comes with lots of fancy phrases which can be more than a little off-putting at first but, once you understand them, you wonder what all the fuss was about! One of those phrases is Custom Post Types.

By default your WordPress site comes with two types of content that you’ll already familiar with:

  1. Pages
  2. Posts

In WordPress language, these are ‘post’ types.

We use our Pages post type for all our standard, static content: our homepage, About Us, Our Services etc.

We use Posts in a section we may call Blog, or News, or Articles etc. A WordPress site will typically have a blog summary pages which automatically lists out all the recent posts so folks can click on them to read the ones they want.

We can expand on these two standard types and create our own post types, hence ‘Custom Post Types‘.

An Example

I’m going to walk through these concepts in light of our Webinars section. However, when reading this, I’d like you to consider how the techniques I’m describing can be applied to your website, and your content.

Webinars

We have a section on our site for our online events & webinars. The section can be broken down as follows:

When I add a new webinar, it automatically appears on the webinar main page.

Webinars occur at set dates and times, as those events lapse, the webinar listing main page automatically moves from the ‘upcoming webinars‘ section to the ‘previous events‘ section.

But, you may ask, can’t you simply do this with Pages and Posts?

In a fashion, yes. Let’s explore how we could have implemented that so you can see the drawbacks and weaknesses.

Implementing via Pages

We could have:

  1. Manually created a page to show our upcoming webinars
  2. Manually created child pages for the individual webinars

Then when we created a new webinar, or a webinar lapsed, we would have to manually amend the webinar section homepage. It’s time-consuming and a tad clunky.

Implementing via Posts

We could have also implemented this via our Posts section.

Now bear in mind we currently already use posts for our Campfire blog where we publish training articles (like this one you are reading).

So we could have added a new Post for each upcoming webinar. This would have given us a unique URL for each webinar (so we can promote the event on social media, and our email newsletter etc) but this would mean that webinars would also appear in our blog section:

Fig 1 – How our Posts currently appears on the Campfire homepage

On the surface, webinars appearing alongside our blog articles wouldn’t have been too weird from a website visitor perspective – as the content is sort of related (but, then again, everything on our site is sort of related!).

This Posts approach has big problems though:

How do I show all the upcoming webinars?

It is reasonable that people will want to go to a section of the site which shows only the upcoming webinars.

But if I’m piggybacking our events into the Campfire Blog, where do I send them to just see all our webinars?

To the main Campfire blog page?

No, that’s not a great experience as that is showing our articles as well as webinars. And I don’t really want people to have wade through our articles when they are really looking for just our upcoming webinars: a website is meant to arrange your information in a way which makes it easy for your website visitors to find the content they are after.

Put another way, we shouldn’t just shoehorn information into existing, standard WordPress areas just because it makes it easy for us to administer.

Solution?

We could be clever here and create a new WordPress Category (more on categories in the next post in this series) called “Webinar” then, if we add that new category to our exsiting & new webinar posts, it’s pretty easy for us to show a page pf results of just webinars.

E.g. here is the page that WordPress automatically creates for our “How To” category series – it’s a page that exists simply because I have a WordPress category assigned to certain posts. So this too could work for webinars”.

There are two key problems with this ‘just use categories‘ approach:

Firstly, this new automatic category page will display all ‘webinars‘ in the order you added them to your site; the most recently added at the top of the page – this may well not be the same as the chronological order of when the dates are coming.

And if you spot the order of your events is wrong, you’ll need to manually go in and amend the Published date for the relevant posts to juggle the order of the page around. In short: a fudge.

Another key problem is that there is no easy, out of the box solution to the fact that this new automatic category page is showing a mix of upcoming webinars and lapsed webinars.

You might think the answer is simple here……

Why not just delete webinar pages after the event has happened?

Yes, you could do this – and doing so would mean your ‘upcoming events‘ category page stays relevant but I don’t think this approach is a very good idea.

A lapsed webinar page is still very useful content for your site.

For example, I recently ran a webinar where I interviewed Mark Schaefer about blogging. After the event was over, I updated that specific event page, replacing the ‘sign up‘ future tense event information with a video recording of the interview, plus some accompanying notes including links mentioned in the talk (it’s a great talk, Mark makes fantastic points – you should watch it).

In short, this is very useful content which is not only helpful to people who attended the event but is also useful for people who didn’t. Remember we are trying to add meaningful content to our websites – this is good for our visitors and good for SEO.

Deleting is bad for SEO

Imagine if we ran 25 events over the next year. That will be 25 extra pages we’re adding to our website based around our central topic of WordPress and websites etc. We are helping to indicate to Google here that we are becoming more relevant on this subject (though my usual caveat here – we don’t do things just for Google).

Simply deleting webinar pages after they lapsed, whilst solving the problem of webinars showing up on our hypothetical category page, would end up throwing the baby out with the bathwater.

Hey, what about two categories?!

Some of you might be one step ahead here with thinking:

The answer is easy! You don’t just have one category for Webinars you have two: UPCOMING WEBINARS and PREVIOUS WEBINARS.

And I won’t argue, this will work in one sense. This would give you two separate category pages you could point people to based on what they were looking for (“Interested in our upcoming webinars? Go here?“, “Want to see our lapsed ones? Click here“). Though you do need to manually change categories on your webinar posts to achieve this – this has fudge written all over it.

How to avoid this fudge

Hopefully you’ve seen from the above that whilst you can add different types of information to your site using a combination of existing Pages or Posts, such an approach does come with drawbacks.

So, what’s the alternative?

Custom Post Types

We use Custom Post Types when we decide that we simply are not willing to settle for the downsides of trying to shoehorn our content in the existing Page or Post structure.

When you have a Custom Post Type (CPT for short) created, it appears as a new item in your WordPress admin area. In Fig 2 below, we see our ‘Webinars‘:

Fig 2 – our Webinars Custom Post Type (CPT)

Note also in Fig 2 that you can see we have Custom Post Types also for Testimonials, FAQs etc

By having a Custom Post Type we are now free of the constraints and limitations that we had when trying to shoehorn that content elsewhere on the site.

If you clicked on Webinars in Fig 2 you’ll see a list of our upcoming webinars

Fig 3 – Webinars

Notice the ‘Webinar Date’ field? That isn’t standard WordPress. We added that field and boy is that useful! We are now free from the constraint of thinking “the date published is the same as actual event date“, now we can have our own date field. For someone who has a degree in Computing, using fields for their correct purpose, gives me a warm fuzzy feeling 😉

Advanced Custom Fields (ACF)

I’m cheating a little, the ‘Webinar Date‘ field is not strictly possible because we’ve simply created a new Custom Post Type. No, we are actually using another handy facility here called Advanced Custom Fields (or ACF for short).

With ACF we can answer useful questions like:

“Hey! So these webinar event things we want to show on the site? What information will people want to know about them?”

People will want to know:

  • The title of the event
  • Webinar date – when it is running (or whether it has lapsed)
  • A description of the event
  • How much the event costs (or if it is free)
  • How they register for the event

If we create new custom ACF fields for key information that we want to model, then our life is made so much easier.

Let’s take “Webinar Date” as an example.

Setting this up as a new field means that:

  • Any new Webinar MUST have a Webinar Date (not optional)
  • And that Webinar Date is actually a date field (not a number, or picture, or text)
Fig 4 – our Webinar Custom Post Type Page

As you see in Fig 4, our main page for our Webinars can now easily show the upcoming events (in the right order) because we have modelled that ‘Webinar Date‘ field.

Note also from Fig 4 the ‘Price‘ field. For each event, we model whether the event is free, or if we charge for it – the above two events are free and our Webinars template detects that and adjusts its display accordingly.

If the event was paid one, it displays differently:

Fig 5 – a paid event

Individual Webinar Pages

Let’s take a look for how an individual webinar looks like when editing:

Fig 6 – Editing our Webinars

In Fig 6 you’ll see some of the custom fields we have set up for our webinars. We have:

  • the date / time
  • (if there is no date / time, the event will show as TBC)
  • The price (set to 0 for free, or blank for TBC)
  • The registration link
  • Registration link label
  • etc

If we then look at how these fields display, we can start to see some of the real magic coming together….

Fig 7 – Advanced Custom Fields

Look at the top left of Fig 7 and you’ll see how key fields such as event date, price, and registration link are displayed (in the blue block area).

You’ll also see a snazzy countdown clock which actually ticks away on the individual webinar pages themselves.

How do you use this?

Custom Post Types and Advanced Custom Fields can really add magic to websites – allowing your content to shine, and creating fantastic user experiences.

When we are designing a new website for a client, or enhancing an existing one, we’ll autoamtically be thinking in these terms.

However, if you are not looking for a new site, or to get custom dev work done then all is not lost….

Plugins

Let’s stick to the example of Webinars.

Let’s say you want to run Webinars on your site, you want to avoid the mess of putting them into Posts, and you don’t want to investigate in getting us to develop for you. One answer here is to see what Plugins are out there.

For many sites that need events, a plugin such as The Events Calendar is perfect. It’ll come with a variety of events related functionality which should allow you to create something similar to what we’ve done.

The makers of The Events Calendar plugin will have used facilities such as Custom Post Types, and Advanced Custom Fields to create a facility which broadly fits everything that people who want to run events on their website will need.

We didn’t go that route for obvious reasons – we already have the development and design skills to implement things like Events. And implement them in a way that is exact to our requirements – so there is no need to compromise here.

Themes

As you may know, Themes are pre-packaged, shrink-wrapped designs which control the look and feel of our website.

Certain Themes too may well be making use of Custom Post Types etc – e.g. some themes may well add new post types to your left hand WordPress menu.

DIY

If you are feeling brave, here is some more technical reading on creating custom post types. Feel free to look at this page as well.

The main problem I have with a lot of plugins that allow you to create new Custom Post Types, is that many don’t then automatically give you the ability to see them on your site (you need extra steps for that, perhaps even programming). Toolset looks interesting though.

Note: I appreciate there isn’t much help here for you to do-it-yourself, I’m going to do some more research and if I can find a DIY solution which applies to most people, I’ll blog a guide about it.

Main Takeaway

The main takeaway I’d like you to have is this:

Think about what information your site needs to convey, and consider how Custom Post Types and Advanced Custom fields can help.

Don’t just settle for Pages and Posts.

Coming Next

In the next article I’m going to describe another useful WordPress facility and how we are using that to expand on our Webinars section.

Joel

p.s. we have a free event on Friday occurring in our Facebook Group – we’ll be chatting about content so this may well come up.

Tags:
No Comments

Leave a Reply