What is WordPress custom fields

WordPress custom fields are used to add extra information to your pages, posts or custom post types. The data (meta-data) of custom fields consists of key/value pairs. The key is the ‘name’ of the field and must stay the same for all posts within post type. The value, on the other hand, is the data that will change from post to post as your posts will use the value of the key to display it.

To add custom fields to your WordPress website, you can use either default WordPress custom fields or Advanced Custom Fields plugin for more advanced custom fields option.

An example of custom fields usage would be – use get_post_meta where you can specify the key of the custom field you want to display.

get_post_meta($post_id, $key, $single);

As for the $single, it can be either true or false where true will return a single value as a string and false returns array.