I'm creating a plugin for creating Landing Pages.

I use custom post type and custom fields for the landing pages, but i need to add some on-page options for each entry. For example i need to have a an option(check box) for hiding the header(header is edited through a WYSIWYG custom field) on a specific landing page.

I searched for different option "frameworks" and i found Redux ( https://github.com/ghost1227/Redux-Framework ) that works for plugins and also uses WordPress Settings API.

The examples of Redux and any other framework i found as well as any tutorials i found online about creating settings/options pages are for general options but i need to have those options in the editing screen of my specific custom post type.

I'm not a PHP guru but i'm trying and willing to learn, any help will be appreciated or at least if someone can point me to the right direction it would be nice.

Cheers, Stelios

3 Answers 3


What you want is a custom meta box.

Searching this site will give you plenty of examples as well, but here's a brief run down.

You hook into add_meta_boxes and call, appropriately, add_meta_box.

add_action('add_meta_boxes', 'wpse87567_add_box');
function wpse87567_add_box($post_type)
    // $post_type the "page" on which the `add_meta_boxes` action is being fired
    // It could be commends or could be a post type. It's really only
    // useful if you want to dynamically add a meta box everywhere.

        'wpse87567-box', // the meta box ID, can be anything
        __('A Meta Box', 'wpse'), // your meta box title
        'wpse87567_box_callback', // the callback, the function that spits our your meta box contents (eg. fields)
        'landing_page', // the post type to which you wish to add the meta box
        'side', // where should you put it? side, normal, or advanced
        'low' // how important is it? high, core, default, or low

function wpse87567_box_callback($post)
    // post is the current page's post object, use it to fetch your additional
    // meta data via `get_post_meta` or the like.

    // spit out your HTML fields here

To save things, you hook into save_post and check to make sure you're not doing an autosave, the post types match up, the nonces check out, and the the current user can actually edit the post

add_action('save_post', 'wpse87567_save', 10, 2);
function wpse87567_save($post_id, $post)
    // make sure we aren't doing an autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {

    // check if your post types match: do you need to save...
    if ('landing_page' !== $post->post_type) {

    // If you used a nonce above, and you should have, check it here.

    // See if the current user can edit the post
    // `edit_post` should be whatever capability your post type was
    // registered with. Maybe be `edit_page` or `edit_landing_page`, etc
    if (!current_user_can('edit_post', $post_id)) {

    // if you're here, save stuff.

    if (!empty($_POST['some_field_from_the_callback'])) {
    } else {
        delete_post_meta($post_id, '_your_meta_key');

You're looking for Meta Boxes.

The Codex has lots of great info about meta boxes. Look at the examples on that page and adjust to fit your needs.

There are lots of plugins out there that provide similar functionality. I've used the WP Alchemy Class with much success; it's very developer focused, and not for the faint-of-heart. I also have dabbled a bit with Advanced Custom Fields plugin, which is easier to use but doesn't always do exactly what you need.


Redux also has a metaboxes extension that ties your panel and metaboxes together. ;) http://reduxframework.com/extensions/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.