0

I have a custom post type to display informations of book. Then I created a metabox for it. And:

I need to add a warning system (like: for kid, violent, mature, adult, etc...) chosen by multi checkbox, then display them to the CPT by warning icons (png or svg)

How can I use array to create this options, save and display?

Here's my metabox addding:

global $st_series_cpt;
$prefix = 'st_series_';

$wpar_meta_box = array(
    'id' => 'series-post-meta-box',
    'title' => 'Information',
    'page' => 'stfic',
    'context' => 'normal',
    'priority' => 'high',
    'fields' => array(???)
);

1 Answer 1

0

There is no "fields" argument to add_meta_box(), which I assume is what you are using and not some code-bloat-ie helper function/class nonsense. And you've not identified a callback, which is the key. Create a callback and put your "warning" array in that, along with code to create your checkboxe/radio-boxes, or whatever you need.

$wpar_meta_box = array(
    'id' => 'series-post-meta-box',
    'title' => 'Information',
    'callback' => 'st_meta_box',
    'page' => 'stfic',
    'context' => 'normal',
    'priority' => 'high',
);
function st_meta_box($post) {
  $warn = array(
    'kid', 'violent', 'mature', 'adult'
  );
  // Code to create form markup
}

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.