
Some of the code and concepts in this post are outdated, please view the following post: Post Options API is Almost Ready for Action.
Remember Custom Fields? Yeah, the ones with a not so friendly user interface, designed to assign some meta data to posts, pages and other post types, that would hopefully appear somewhere in the post content through a function called the_meta. The most known example is the “mood” one, but theme and plugin developers nowadays use custom fields (i.e. post meta) for entirely different purposes, like title rewrites, meta description, per post/page custom CSS, AdSense banner codes, social bookmarking links display, layout configuration and much more.
The problem with custom fields is that while being okay for developers, they’re somewhat scary and sometimes frustrating for the less savvy people and it has been like that for years. To avoid that problem, developers are using custom meta boxes with their own custom form fields which are generally wrappers around the original post meta. That way the end-user can set their mood to Happy in a simple drop-down select box or perhaps a radio button group.
The trouble however is that there is no unified way of doing this, so each developer has to come up with their own, meaning redundant code, new UI, new learning curve for the end user and less flexibility. There’s a similar situation with custom admin screens and settings pages, hopefully being solved by the Settings API and today we’ll take a look at a similar concept for post meta data — the Post Options API. Permalink