Custom fields add information to WordPress content. When you need more than title or body, you’re looking for custom fields.
Types plugin lets you easily add custom fields to your content. Create custom fields for checkboxes, radio-groups, images, text input, drop-downs and many other field types.
Types plugin is 100% free. When you register, you also get access to Types support forum.
1. Adding Custom Fields to Your Content
The standard WordPress editor includes a title and body. When we need to include other information, we use custom fields.
For example, look at this ‘project’ page:
Besides the title and body, you’ll also notice an image and testimonial. Types created these fields. One of them is an image field and the other, a multi-line field. Of course, there are other field types to choose from.
2. Creating a Custom Fields Group
The box with these fields is called a Fields Group. When you want to add custom fields to edit pages, first, you need to create a new Fields Group. Then, you can display it on different edit screens.
To create a new Fields Group, click on Types->Custom Fields. Then, click on “Add a custom fields group“.
You’ll enter the name of the group, give it a description and you can start adding fields to it.
3. Adding Fields to Groups
Now, it’s time to add fields to our group. Click on the field types at the top-right of the screen. Each click adds a field.
All fields have these attributes:
- Name – the ‘human’ name of this field. This is how it will appears in the WordPress GUI.
- Slug – the ‘computer’ name of this field. It must contain only English letters, digits and underscores.
- Description – a piece of text that would appear next to the field, in edit screens, explaining it.
- Validation – check this box if you want to make this field mandatory when editing content.
Some fields, like check-boxes, radio options or Skype require additional information.
After you add field to the group, remember to save it.
You can re-order fields inside the group by clicking on the arrows icon, next to each field, and dragging it up or down. The red X deletes fields from the group.
4. Controlling Where Custom Field Groups Display
Field Groups can display in different editing screens. Scroll to the top of the group setup page. You’ll find a section titled “Where to display this group“.
You can control the custom fields group display according to:
- Content type, like post, page or custom types
- Taxonomy terms, such as tags, categories or your custom taxonomy
- Page templates – if your theme uses different templates, you can display the right custom fields used by the template
- Data-dependent – according to the values of other custom fields
Click on the ‘edit’ button next to each display criteria to set it. If you’re using more than one display criteria, you’ll see an option to display the group when all conditions are met or when at least one condition is met.
5. Displaying Custom Fields
So far, all we talked about is how to define custom fields in the WordPress admin. But, you’ll surely want to also display these custom fields in your site’s public pages.
You can display custom content either by writing PHP and using Types API, or using Views plugin without any coding.
Types PHP API makes it easy for coders to display custom fields. The types_render_field call outputs each field with its special formatting and supports different attributes for different field kinds.
Views let’s you design page templates and display custom fields, without coding.
Types is a free plugin for managing custom post types, taxonomy and custom fields.
The complete Toolset package makes Types even more powerful. You’ll be able to build entire websites from the WordPress admin without any coding.