What are Custom Fields?
Custom Fields are metaboxes that are used to input metadata that is related to your post. When you add a new post in WordPress, you’ll see these draggable boxes which are used for to store information about your post. Examples are author and excerpt. Another is custom fields. If you can’t see custom fields, click on the Screen Options tab and check the Custom Fields box.
Here you can add pieces of information to your Post which is then output by your theme. The WordPress Codex provides a useful example of Custom Fields that you might want to add to your Posts:
- Mood: Happy
- Currently Reading: Cinderella
- Listening To: Rock Around the Clock
- Weather: Hot and humid
While a Custom Taxonomy is way to organise and classify your posts into groups, Custom Fields let you store unique information that applies to your Post, Page, or Custom Post Type.
Uses for Custom Fields
There are lots of plugins and themes around that use Custom Fields for you to add specific information to your Posts, Pages, and Custom Post Types. Examples of this are:
- Price, weight, and dimensions in your eCommerce store
- Client name and company for your testimonials
- Number of rooms, bathrooms, and floor size to your real estate listings
- Ratings to your gaming reviews
- Dates, time, and ticket price for your events
Creating Custom Fields
As with Custom Post Types and Custom Taxonomies, you can code your Custom Fields yourself. With a plugin such as Pods, however, you can create Custom Fields through the WordPress interface. Whenever you create a Custom Post Type you can add Custom Fields to that Post Type. In the example below, the number of pages is being added to the Books Custom Post Type.
This is then added to the post editing screen for your Books Custom Post Type. The information stored is specific to the post that is being added and can be used for querying and displaying data.
It’s worth noting that Pods also allows you to add Post Meta to your taxonomies so you can have specific information applied to each taxonomy term. As Taxonomies don’t natively support Custom Fields in WordPress, these are stored in a separate database table, in a similar fashion to Advanced Content Types.