Custom fields are used in WordPress to store additional information about a post. They are normally available to you in the Write Post screen as Key/Value pairs.
You can use custom fields to display information on the site or for some other kind of special processing (like storing a post's expiration date).
To add a custom field from the code, you can use the add_post_meta()
function:
add_post_meta($post_id, $meta_key, $meta_value, $unique)
post_id:
This parameter contains the ID of the post where the custom field is to be added.meta_key:
This parameter contains the key identifier (such asmood, job-type)
.meta_value:
This parameter contains the value for the key (such ashappy, temporarily
, and so on).unique:
This parameter contains is used to decide whether you want this key to be unique. WordPress supports multiple values for the same key, and if the value set is unique, only one instance for the given key is allowed.prev_value: This contains...