What are post types, taxonomies and custom fields?

Post items

When you add a blog post, it’s technically called a post item. A page is also considered a post item (I know, it’s confusing). Same goes for an attachment (media). A post item is what WordPress calls any content item, regardless of its post type.

Post types

A post type is a grouping of post items that share similar properties.

Posts, Pages, and Menus are core post types. All posts have boxes for “Categories” and “Tags”, and all pages have boxes for “Template” and “Parent Page”. Post types allow for better organization of content throughout your site.

You can also create custom post types. Some plugins register their own post types too. For example, WooCommerce uses a “Products” post type for storing its products.

Creating a custom post type

WordPress provides a register_post_type function that you’d use to create your own post type. This code could go either into your theme’s functions.php file, or into a custom plugin.

You could also use the Custom Post Type UI plugin to visually create new post types.

Taxonomies

A taxonomy is used as a way to describe or organize your post items.

A taxonomy consists of terms. For example, a taxonomy named “Meal Type” would contain terms like “Breakfast”, “Lunch”, and “Dinner”.

WordPress core includes 2 taxonomies (“Categories”, and “Tags”) that are attached to the “Posts” post type. When registered, a taxonomy can be associated with one or more post types.

A taxonomy includes built-in listing URLs. For example, you can set it so that /meal-type/dinner/ will show users a listing of Dinner items.

Taxonomy terms can be used for filtering, but not sorting.

Creating a taxonomy

Similar to registering post types, WordPress provides a register_taxonomy function. You could also use the Custom Post Type UI plugin.

Custom fields

Custom fields are extra pieces of information that you can attach to post items.

Custom fields do not include built-in listing URLs, but you can both filter and sort by custom fields (unlike with taxonomies).

Long text, text that’s relatively unique (such as SKUs or street names), dates, and numeric values are usually stored as custom fields.

Creating a custom field

We generally recommend using Advanced Custom Fields (ACF). See or Advanced Custom Fields guide to learn how to create and use custom fields.

Planning considerations

Let’s say you’re creating an “Events” post type. You want each item to contain the following data:

  • Title
  • Description
  • Event type (Seminar, Job Fair, Trade Show, Gala)
  • Event date
  • Location
  • Speakers

Title and Description are easy; every post type includes those fields by default so we can just use those.

Event type would generally be a custom taxonomy. It’s safe to use a taxonomy here because sorting isn’t necessary (or particularly helpful) in this instance.

Event date would be a custom field (ACF provides a “Date” field type). Being able to sort by date is important here.

Location depends on how you plan on using this field. If the event has a specific address, I’d recommend using an ACF “Map” field because it saves the location’s coordinates (for use along with a Proximity or Map facet). Alternatively, if you want each location to link to its own detail page, I’d suggest creating a new “Location” post type. Then you could add an ACF relationship field on your Event post type to associate the event with its location(s).

Speakers is similar, in that “it depends”. It could be a text or wysiwyg custom field, or you could create a “Speakers” post type and link to it with an ACF “Relationship” field.

Further reading

https://developer.wordpress.org/themes/basics/categories-tags-custom-taxonomies/