The Piklist folder structure makes it very easy to create Meta-Boxes, Settings Sections, etc, with limited code. Sometimes, however, you may need to insert a field in a specific place. Usually this is tied to a WordPress hook.
The Piklist field
function, can be used outside the Piklist folder structure, and placed inside a standard function.
For this tutorial, we will insert a “Subtitle” field, under the Post Title field. A few things:
edit_form_after_title
. This hook allows you to insert information after the Post Title field.Here’s the code:
function my_add_sub_title() {
piklist('field', array(
'type' => 'text'
,'field' => 'text'
,'template' => 'field' // format the field without a label
,'attributes' => array(
'class' => 'large-text'
,'placeholder' => 'Enter subtitle here'
)
));
}
add_action('edit_form_after_title', 'my_add_sub_title');
This documentation is a community effort. Please create an issue or pull request to help!