Well, it turns out that my release of a “reloaded” version of my hugely popular custom fields theme code was a bit premature. I quickly realized that even though (or especially because) my target audience is developers, the code should become a plugin. The field definitions should be separate, in the theme, so the core plugin code can be easily update. D’uh!
So, while I’m not officially releasing the plugin yet on the WP repository, I thought I’d kick off a public beta. Check out the SLT Custom Fields plugin. Documentation is incomplete, and bugs may exist. However, all functionality seems to be working good on test sites. Use on production servers at your own risk, but please report any problems here.
I’m hoping this will grow into a powerful and stable tool for WordPress custom theme developers.
To get you going, here’s an example for registering a box of custom fields. This code should go in your custom theme’s functions.php file.
NOTE: Please refer to the plugin’s readme.txt for the latest details on parameters and usage.
slt_cf_register_box( array( 'type' => 'post', 'id' => 'seo', 'title' => 'Search Engine Optimization', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'name' => 'title', 'label' => 'Title', 'description' => 'This title will get used in the top of the browser window, as the page heading, and when the page is bookmarked.', 'type' => 'text', 'scope' => array( 'post', 'page' ), 'capabilities' => array( 'edit_pages' ) ), array( 'name' => 'description', 'label' => 'Description', 'description' => 'If there's a description here, it'll get used for the <code>meta</code> description, which replaces Google's automatically generated description when the page appears in search results. It should be less than 160 characters long.', 'type' => 'textarea', 'height' => 10, 'scope' => array( 'post', 'page' ), 'capabilities' => array( 'edit_pages' ), 'charcounter' => true ), array( 'name' => 'keywords', 'label' => 'Keywords', 'description' => 'Enter comma-separated keywords that summarize the content's subject matter. Try not to exceed around 160 characters.', 'type' => 'textarea', 'scope' => array( 'post', 'page' ), 'capabilities' => array( 'edit_pages' ), 'charcounter' => true ) ) ));