How to Add WordPress Custom Fields to Your Posts and Pages
In the following section, we’ll help you create your own custom fields using two different methods.
The first method involves installing a dedicated plugin to simplify the process. The second one requires that you manually edit your WordPress theme files.
Use the Advanced Custom Fields Plugin
There are a lot of plugins to help you quickly add WordPress custom fields. The most popular one is Advanced Custom Fields (ACF).
It comes with an easy-to-use user interface that allows you to add 30 custom field types with only a few clicks. To get started, you need to install the plugin and activate it.
Go to your dashboard and into the Plugins → Add New tab. Once you’re there, use the search bar to look for Advanced Custom Fields.
Go ahead and click the Install Now button. Wait until the text changes to Activate, then click on it once more.
Once Advanced Custom Fields is up and running, you’ll see a new Custom Fields tab appear in your dashboard. Clicking on it will reveal a list of custom field groups, which should be empty.
To set up a field group, simply click on the Add New button at the top of the screen.
Continue by clicking on the Add Field button. Pick a label for your new field that will also serve as its name. You also need to choose what type of field you want to set up – some of the options include text, checkbox, and email.
For this example, we’re going to create an Email field to collect every author’s email address.
To write a set of instructions, simply fill in the provided field. For example, you can add “Please fill out your email address before publishing your post.”
Although this step isn’t necessary, it helps other administrators on the website know what to do with the custom field.
Moving on, you’ll also need to indicate whether this is a required field or not. This way, it will not be possible to save posts or pages without filling it out.
There are a few other advanced settings you can adjust if needed. Once the basic properties are filled out, scroll down to locate the Close Field button.
Clicking on it will automatically add your custom field group to the list. To add more custom fields, simply choose the Add Field button and repeat the process.
Once you have created your custom field groups, you’ll need to configure where these custom field groups will show up by customizing the Location settings.
There’s an option labeled Show this field group if that you can use to configure the display options.
In this example, we configured the custom field to show up on regular posts. If you want, you can add more than one location to display your custom field using the Add rule group button.
Finally, hit the Publish button to save your new custom field.
When your field is ready to go, open the WordPress post editor. The custom field will show up right under the text editor.