WordPress Custom Fields
When writing content for your WordPress site, you’ll probably have noticed that certain basic details are always displayed. These include author names, dates, titles, and so on. This information is called metadata, and WordPress usually creates it automatically.
By using your own custom fields, however, you can edit your posts’ and pages’ metadata to display whatever you want. The custom fields tool is usually hidden by default, but you can easily enable and start using it. What’s more, there are plugins that help to refine this useful feature even further.
In this post, we’re going to explain what custom fields are and how to implement them in WordPress. Let’s get to work!
What Is a WordPress Custom Field?
WordPress custom fields enable you to add additional information to your posts and pages. As we mentioned earlier, these details are stored as ‘metadata’. To display that metadata, you can make a few basic alterations to your WordPress theme.
WordPress posts come with some basic metadata already, but custom fields give you an opportunity to add more. You can include any information you like in them. This could be ratings for products you’re writing about, for example, or even music you are listening to as you write each post.
Why Use WordPress Custom Fields?
WordPress custom fields permit you greater control over your website. However, that isn’t their only benefit.
Using custom fields also gives you an opportunity to be more transparent with your website visitors. These fields let you add information that would otherwise not be displayed. Some of these details help your audience relate with your content at a deeper level.
For instance, displaying the mood you were in when writing a post can help readers interpret it in the right way. As another example, adding dates to specific content makes it clear when the information within might no longer be relevant.
Advanced custom fields are used on a lot of WordPress websites, but are most useful for larger sites with a lot of content. This can include multi-author blogs, e-commerce and business portals, and even multilingual sites.
How to Implement WordPress Custom Fields
In order to add WordPress custom fields to your content, you will first need to open up the page or post you’d like to use. Then, you can simply walk through the following three steps.
Step 1: Enable Custom Fields
Custom fields are hidden by default on most WordPress sites. To make them visible, select the Screen Options tab at the top of any WordPress editor page, and choose Custom Fields:
This will open a new dialog box below the post or page editor.
Step 2: Create a Custom Field
In the new Custom Fields box, click on Enter New to create your first custom field:
Give your custom field a simple and descriptive name. Then, enter the information you want to display in the Value box. In our example, we’re creating a custom field that will display what song the author was listening to while writing the post, so we’ve entered the song’s title under Value.
Step 3: Add Code to Your Theme File
Once you’re done with the previous step, select Add Custom Field. This assigns the information to your post as new metadata, but won’t display it on your site yet.
To make that happen, you need to add some code to your WordPress theme. Head to Appearance > Editor, and look for the single.php file:
Here, you can add any code you like, depending on how you want your custom metadata displayed. Just make sure you add it before the line:
<?php endwhile; // end of the loop. ?>
As an example, we could use the following code to display the song title we entered in the last step:
<p>Listening to: <?php echo get_post_meta($post->ID, 'song-title', true); ?>
Again, you can use just about any code here, simple or complex. The only limit to what you can accomplish using WordPress custom fields is your own creativity.
Top Custom Fields Plugins
The above process works just fine for adding custom fields to your WordPress content. However, you can also use plugins to simplify the process and expand your options. Let’s look at a few tools that can help you get the most out of the custom fields feature.
1. Advanced Custom Fields
Advanced Custom Fields boasts a clear and friendly interface design, which makes even its more complex features easy to use. It lets you add custom fields nearly anywhere on your site, customize them, and display them however you’d like.
This plugin also provides you with more than 30 custom field types to use, including email, text, number, image, and password fields. If you like, there’s also a Pro version with even more features.
2. Pods
Pods is another plugin that greatly expands what you can do with your WordPress custom fields. It provides a clean interface that lets you manage your fields and customize them fully. In addition, it offers a variety of display options.
This handy plugin includes more than just custom fields functionality, however. Pods also helps you manage custom post types, categories and tags, and a lot more. If you’re looking for a tool that can help you get a lot more control over your WordPress content, this is one to check out.
3. Custom Field Suite
The previous two custom fields plugins are very feature-heavy, which can be handy for advanced users. However, what if you want something a bit simpler and more straightforward? That’s where Custom Field Suite comes into the picture.
This plugin provides only the functionality you need to manage your custom fields more fully, without any extra frills. It includes 14 field types, such as text, date, term, and user fields. It’s also very lightweight, so it should have little to no impact on your site’s performance.
Support for More WordPress and Digital Experience from WP Engine
If you are just starting out with WordPress custom fields, you might need help with the technical aspects. Here at WP Engine, we are all about helping to make your WordPress website work for you. Of course, we also provide reliable and powerful hosting plans, along with a stellar support team.
For all your WordPress needs, we’d recommend checking out our Resource Center. There, you can find lots of essential information on WordPress, eCommerce, SEO, security, analytics, uptime, and so much more!