Using WordPress Custom Fields For Next-Level Functionality

By Carey Wodehouse

WordPress is the leading content management system, beloved for its flexibility, customizability, and incredibly user-friendliness. One of WordPress’s core baked-in features that makes that high degree of customization possible is Custom Fields—something you’ve probably used without even knowing it. (Ever used the Yoast SEO plugin? That’s a custom field in action.) What you should know, however, is that this little function is capable of amazing things.

Here’s a look at how custom fields work and a few examples of ways WordPress developers have implemented for next-level WordPress development.

What Are Custom Fields?

If you’ve ever worked in a WordPress dashboard, you’re familiar with post and page editors. To add content to a post or page, you type it right into the text editor, format the text, add media, then hit publish. But to add specific, related information about that content to the post, there’s a separate tool: Custom Fields. These allow you to add in specific, pre-formatted fields to your post or page known as “metadata.”

What do we mean by metadata? Say you have a blog where you post recipes, and for each recipe post you’d like to include information like its source, when you tried it, how many times you’ve tried it, and how long it took to prepare. By creating custom fields, you can easily enter this information into a separate section, which both makes it easier to remember what to enter and ensures that block of information looks the same on each page. For clients who have lots of next-level requirements of their WordPress sites, it’s easy to see how coding in custom fields can make their life easier—especially when it comes to things like formatting consistency.

Below, a blank custom field. Note: You may not see this if it has been hidden in your dashboard’s Screen Options.

Below, adding a new custom field with name and value:

In the above image, that box you see found below the text editor on a post is known as a “metabox.” Add any custom field you want to the custom fields metabox—then, with some code added to your site’s functions.php file and template files, WordPress will include the field(s). Add a conditional statement to that custom field, and it won’t show up on the post if nothing’s entered into the field. Custom fields can be used to alter RSS feeds, sidebars (and other areas outside the loop, like footers and headers), and more.

What Are Advanced Custom Fields?

As you can see, the above “metabox” is pretty boilerplate and not super intuitive to your average user. Compared with a clearly labeled form that tells you what to enter, it leaves a little to be desired. Regular custom fields also limit you to inputting text, which is where the Advanced Custom Fields plugin comes in.

Advanced Custom Fields (and Advanced Custom Fields Pro) allow you to create a more user friendly UI, give you more flexibility with your data and functionality, and let you completely customize your dashboard with metaboxes. Rather than Go to the full article.

Source:: Business 2 Community

Be Sociable, Share!