How to add post meta data before it has been saved or published? Can’t use transitional hooks. After digging through code, you have to use add_meta_boxes action.
Let’s say you have a custom post type book. Each book has several properties (meta data), such as the author, the publisher and the publication date. Now, WordPress has a nice feature called Custom Fields. It is an interface for adding meta data to your posts: a meta key on left and meta value on right. When a new book is created, however, Custom Fields are empty because no meta data has been added to the book yet. The question is: how can we add custom meta data to a post (book) before it has been saved as a draft or published?
Continue reading “Add new post meta data on ‘Add New’ page programmatically”