Custom field data can be added to a post in the "Custom Fields" section of the Post Editor, or programmatically using update_post_meta(). update_post_meta() is also the function to change a custom field's value for a specific post.
Once stored, custom field data can be accessed using get_post_meta(). This function always requires a post ID; in The Loop, you can find this ID with get_the_ID(), but outside it you'll need to use other methods.
The final noteworthy function for working with custom field data is delete_post_meta(), which destroys a given custom field's data for a given post.
Creating attractive user interfaces for users to input and change custom fields is difficult and labor-intensive in WordPress. Several good plugins and projects exist to solve the problem, and it's worth using those before attempting the process by hand.
In this chapter, we'll discuss how to a...