Customizing your WordPress: creating custom posts with CPT

These days, a big chunk of my job as an educational product manager specializing in WordPress is teaching folks how this tool works. Since part of my gig is helping people make the best decisions possible given their specific context, I thought of throwing together some posts about WordPress.

If you’re diving into the world of website creation using WordPress, it’s crucial to grasp the concepts of “post type” and “Custom Post Type (CPT).” While they might sound like techy terms at first glance, mastering these elements is key to understanding how to customize your site according to your specific needs and offer a unique experience to your visitors.

In this post, I’m gonna break down the differences between post type and CPT in WordPress, highlighting their distinct characteristics and providing valuable insights to help you make informed decisions when customizing your site.

What is WordPress?

One of the first things you need to grasp about WordPress is that it’s a Content Management System (CMS). A CMS allows you to create and manage your website with little to no need to tinker with code.

WordPress handles the actual content (words and images), but also how they’re displayed (their appearance). Although it started its life primarily as a blogging system, WordPress has since been refined and expanded. Many web applications use WordPress as a foundation – it’s evolved into a more robust system. For instance, we at Poly Studio specialize in creating and managing complete learning platforms on WordPress. We have clients with 100,000 students on their platforms.

But WordPress doesn’t stop there. You can have fully functional e-commerce sites, community management systems, job portals, and even a simple portfolio for a filmmaker.

Take a peek at our portfolio for some inspiration on what’s possible with WordPress: https://en.polystud.io/case-studies/

Understanding the history of WordPress is gonna make a difference.

WordPress was born in 2003 as a fork of another content management system. Initially designed as a blogging platform with the option to create other types of pages, it started with one content type: blog posts. They later added pages, plugins, media, and so on.

Each of these content types (post, page, media…) is called a Post Type. Yeah, we know, it’s confusing: the posts on your site are one Post type, while pages are another Post type. We’re mentioning this because it’s gonna be important. But remember, WordPress manages different content types, but officially, they’re all called Post Type.

So, what are the other Post Types? Pages, attachments (or media), and revisions are great examples of other post types. Therefore, almost every time you’re gonna do some customization on your site, you’ll hear about CPT, or Custom Post Type. They’re the heart of customizing your WordPress.

If you’re adding LearnDash to your WordPress, know that it adds Courses, Lessons, Topics, Quizzes, Questions, Certificates, Assignments, Essays, and Groups as CPTs. Just like WooCommerce adds Product, Coupons, and others as CPTs. Almost every plugin that allows you to add new content to your site adds a CPT, as a rule of thumb.

So what’s a Post Type?

Post Types are the different ways you can organize your content in WordPress.

There are 7 default post types in WordPress: posts, pages, attachments, revisions, navigation menus, custom CSS, and Changesets.

Let’s quickly break some of them down.

Posts:

This Post Type is what you’d expect: chronological in nature, mainly used to report news, explain a topic, or just share a personal take on something.

A post can have categories and tags added (called taxonomy), providing more info to your user as well as a way to organize your posts, making it easier to find useful info.

Page:

A page is typically used to display content like the home page, author page, contact page, and so on.

Pages can be static or dynamically generated: static content doesn’t change, but dynamic content changes based on predefined factors.

For example, a home page might display static content like images of your office or logo, but also have dynamic content blocks like the latest products added to your online store. These products are dynamically generated because they can change based on a predefined set of parameters.

Pages don’t have built-in taxonomy (categories or tags). They use different ways to structure their hierarchy.

Attachment:

An attachment is any media you upload to your WordPress site, whether it’s an image file, PDF, or spreadsheet. Every time you upload any media file through the “Add Media” button, it gets stored here.

There are a few other post types like revisions, navigation menus, custom CSS, and changesets. But these aren’t used for daily content creation; they’re admin tools. Let’s skip those for now.

Let’s dive into Custom Post Types.

It’s pretty common and easy for those mentioned post types to be insufficient for a site, yet people still try to shoehorn a certain Post Type to fit their needs. But inevitably, they’ll end up frustrated because the default post types might not cut it, and they’ll bang their heads trying to force them to fit their needs.

No need for that: WordPress can handle custom post types, with their variables and fields.

Custom post types are exactly what you think they are: unique post types for your site. You can use them to customize your site and display content exactly how you want.

For example, if you’re running a bookstore’s website, you might need to list the available books. And books have page numbers, author, publisher, edition, author bio, translator, publication date, and many other variables.

So, you not only need to create a new Post Type, but also create new variable fields for them.

These new variables added to your editor are called custom fields. You can also add custom fields to your regular pages and posts, not just custom post types.

You can create your CPT, custom fields, and taxonomies using plugins like Advanced Custom Field or Custom Post Type UI. Let’s not get into that tutorial to avoid overcomplicating things.

Remember the taxonomy? We mentioned categories and tags as a special group of fields called taxonomy.

Still using the bookstore example: categories usually aren’t mentioned in books. Instead, people use genres like romance, young adult, fantasy, and so on. Tags can be used as topics, like written by a woman, cyberpunk setting, plot twists, first-person narration, and much more. Thus, you can even tweak the taxonomy of your custom Post Type.

Remember: the taxonomy of a Post Type is its categories and tags.

Custom Post Type, or CPT, is the best way to achieve this level of customization for your site.

The most common mistake when working with Custom Post Types.

A common error among beginners is trying to handle custom content types without actually creating a Custom Post Type: they end up simply creating pages in WordPress and manually inserting information into each of them. Imagine managing a bookstore and filling WordPress with 100 pages, all designed and written manually.

Here comes the problem:

  • First: if they want to change the layout later (which is pretty much certain they’ll want to), they’ll have to do it manually for each of the hundred pages.
  • Second: they make the search experience worse for the user since the information isn’t well stored in individual fields (which makes it impossible to search by filters, for example).
  • Third: the site becomes messy, with institutional pages mixed with post type pages.

The solution? Single Post Page.

Just imagine: creating 100 pages one by one or creating a page template that automatically pulls information from the post type you want to display and fills in the gaps. That’s what we call a Single Page: a template that automatically fills in the information based on the post type being displayed.

With the Single Page, if you need to change the layout, just modify the template and all the pages will be updated automatically. This makes management much simpler and easier. But for the Single Page to work, you need to create a Custom Post Type (CPT).

The process goes like this:

  1. You create a custom post type.
  2. Add taxonomies, if needed.
  3. Add custom fields.
  4. Create the Single Post page.

And there you have it! If you want, you can also create the archive page, which serves as a compilation of all Single Pages. So, you don’t need to create a page to display all types of posts. WordPress does this for you automatically.

And how do you do that?

Usually, your theme already includes Single Post and Archive Page for all default post types in WordPress. Moreover, some themes also create these pages for Custom Post Types from the most popular plugins, such as product pages from WooCommerce, course pages from LearnDash, job listings from WP Job Manager, and so on.

But of course, the theme won’t have these pages for the Custom Post Types you create, right? Then you’ll need to manually program these pages or use page builder resources. For example, Elementor and Divi have Theme Builder. When creating the page, you can choose where and how to display the custom fields.

And voilà! Now you have your Custom Post Types and a default page to display them, all organized and presented elegantly.

You’re ready to customize your WordPress like never before!

To summarize everything we’ve talked about here, as there are several terms unique to WordPress.

Post Types: These are the standard content types in WordPress, like posts and pages.

Custom Post Types (CPT): These are content types created to display unique content on your site. Many plugins automatically create CPTs when added to your site.

Custom Fields and Taxonomies: CPTs can have unique custom fields and exclusive taxonomies (categories and/or tags).

Single Post Page: It’s a template page that displays information from a Post Type for each instance of that Post Type.

Archive Page: These are search result pages that show one, several, or all instances of a Post Type.

Themes: They usually include Single Pages and Archive Pages for standard WordPress post types, and sometimes for popular plugin post types.

Creating CPT: To create CPTs, custom fields, and taxonomies, there are tools like Advanced Custom Field or Custom Post Type UI.

Creating Single pages: To create Single Pages and Archive Pages, you can either program them directly or use Page Builders, in Theme Builder mode.

I hope this post helped clarify one of the most important central details for truly customizing your WordPress, going beyond themes. It’s through CPTs that you’ll be able to provide the necessary information to your users. The next step, which requires technical knowledge, is how to make the user interact with your CPTs, adding their own information, saving settings, clicking buttons, etc. But that’s a topic for another content.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *