WordPress Custom Fields is one of its most powerful features. In combination with Custom Post Types, they can convert WordPress to a Custom Application Building Tool, not only a CMS.
How to enable Custom Fields
Custom Fields (also known as metadata) are not enabled by default.
To enable them, press the “three dots” link in the Edit Post (or Edit Page) action and select Preferences.
Then, you can define custom fields and enter values. Unfortunately, the interface is poor. All values are inserted as text. You can modify this functionality, by writing custom code.
To display the field in the front end, you can use
- the the_meta() function to display a list of custom fields
- or the get_post_meta() to display the value of a certain field.
Advanced Custom Fields Plugin
However, instead of reinventing the wheel, you may use a plugin.
Advanced Custom Fields plugin (free and pro version) offers an excellent interface to manage a lot of field types (text, number, date, lookup, image upload, google map, relationship, and more).
To display the field in the front end, it offers the get_field() function.
Remark: you don’t have to enable Custom Fields (see above) if you have installed the Advanced Custom Fields plugin. Moreover, the “Custom Fields” switch box is not visible in Preferences.
Reference
- WordPress Official Documentation – Custom Fields
- WordPress Plugins – Advanced Custom Fields
- Advanced Custom Fields – Official Website
- Advanced Custom Fields – PRO version – Official Website
Entrepreneur | Full-stack developer | Founder of MediSign Ltd. I have over 15 years of professional experience designing and developing web applications. I am also very experienced in managing (web) projects.