7 days of WordPress plugins, themes & templates - for free!* Unlimited asset downloads! Start 7-Day Free Trial
FREELessons: 10Length: 1.1 hours

Next lesson playing in 5 seconds

  • Overview
  • Transcript

2.1 Introducing Post Types

In this lesson, I'll give you an overview of the post types that come bundled with WordPress and show you how to use them.

Related Links

2.1 Introducing Post Types

Hello, and welcome back to this Tuts+ course on custom content types in WordPress. In this part of the course, I'm gonna take you through what post types are available to you in WordPress. Including those post types that are built into the system, and those that you can create yourself. So let's start with the ones that come out of the box. So the most obvious one is posts. A post is what you use to create an update, a blog post, a news item, something like that. And you can see I've got a bunch of them on this website here. One of which is a bit of a mess, let's trash that. So posts are designed to be displayed in your blog feed, so they can be shown in an archive. But you could also show them in an archive for a taxonomy, such as categories or tags, and I'll show you that shortly. So if we go to the front end of the site and here, we're on the blog page, which could either be a page you create for your blog, as I've done, or it could be your home page, all of my blog posts are listed. So blog posts are designed to be displayed like that. So if I click on one, I then get the individual blog post. So you can create template files in your theme to display those posts and display the main blog page or any other archive. So let's have a look at other archives I've got. So here, I've got tag archives, so I've got the blogging tag. And within here, there's just one post with that tag. And I've got a category called Applications. And we'll look at categories a bit more later on, and tags, a bit more later on in the course. For now, we're just focusing on post types. So another post type that you've got available to you is the page. And my About Me page is one example of a page. So that gives you information about me and what I do. Now, a page is designed to be static content. It will never be displayed in an archive, it will never be in your blog feed, it will never go out on an RSS feed if you use RSS. And it's designed to be something that gives people information that is fairly evergreen. So you'll set up a few pages on your site, such as your about page, your contact page, and your home page if you have that as a static page, and you'll leave them. So posts and pages are something that you're probably familiar with, and here are the pages in my site as well. But there are some other post types that are available to you in WordPress. Another one is the attachment. So each media file that you upload, let's take a look at this one. I can view the attachment page for this, and an attachment is a post type. And here it's displayed using its own template. So I can edit that media. And I can add a caption, alternative text, and a description to it. And if I add a description, that will be displayed in my attachment page. There you go, sunglasses. Wow, I've written a lot there, and it's also shown as a caption here. So that's another post type that you have available to you. Now, you won't probably think of attachments as post types, but it's worth mentioning. Because if you wanted to, you could query them and you could list them on an archive page. So for example, if you wanted to categorize attachments in a site that was designed to hold resources, for example. So if you had a lot of files and uploads in your site, you could categorize those, and you could list them in archive files, or via a custom query on a given page. So you would have to make categories or a custom taxonomy available to the attachment post type, but there are ways to do that. So it's just there as an option for you to know that attachments are also post types. Another post type is a menu item. So if I go into Menus, each of these three items in my navigation menu is actually a post type. Well, it's a post of a post type, and the post type is navigation menu item. Again, not something you would ever show in an archive. These are designed to work specifically within the navigation menu. But they are stored in the database in a very similar way to posts and pages. And another post type that is available to you in WordPress is a revision. So if I open this post here, which has had two revisions that you can see over here if you open the Document pane, so not the Block pane, the Document one. So I can then see my two revisions, and I can compare them. So if I want to revert to one of those revisions, I can. Now, this course isn't about revisions, and they're pretty simple to use. But it's just worth knowing that a revision is another post type in the database. So those are the post types that come built in with WordPress. You can also create your own post types. So in this course, we're going to create a post type called cities. And we'll add a number of cities, and they'll all behave in much the same way as a post, but they won't be listed with posts. They won't be stored in the database as posts, they will be cities instead of posts. Now, you may have used plugins that have used custom post types like this. So for example, if you've used an e-commerce plugin, you'll always find that there's a product post type. You might have used a mapping plugin with a map post type, and there's lots of other examples. Post types give you lots of flexibility, because you can store different types of data in your site. And you can then output it in different ways, which you'll learn about later in this course. You can create as many custom post types as you want. I've created sites for clients with as many ten custom post types that have all been output in their own section of the site, with their own custom archive pages, sometimes using custom queries. So it's a really powerful aspect of WordPress. In the next part of the course, I'll show you how to register a custom post type, so you can create custom post types of your own. See you next time and thanks for watching.

Back to the top