Im still trying to learn how to build a comprehensive plugin in WordPress, and Im having issues with meta boxes.

If its possible I would like to have multiple fields in the same metabox, both for aeasthetic reasons but also so Im not writing a new callback function for every single metabox.

Is this possible?

Here is my current code (leaving out the registering of the post type and save function).

add_action( 'plugins_loaded', 'ALCI_member_setup' );
function ALCI_member_setup() {
    add_action( 'add_meta_boxes', 'ALCI_members_create_metaboxes' );
}
function ALCI_members_create_metaboxes()
{   
   add_meta_box('ALCI_member_qualification', 'Member Qualifications', 'ALCI_member_qualification', 'ALCI-members', 'normal', 'high');   
}
function ALCI_member_qualification() {
  global $post;
  echo '<input type="hidden" name="ALCI_member_qualification_noncename" id="ALCI_member_qualification_noncename" value="' .
  wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
  $qualification = get_post_meta($post->ID, 'ALCI_member_qualification', true);
  echo '<p>Qualifications that appear beside the members name, e.g. BSc (Hons) IBCLC</p> 
  <input type="text" name="ALCI_member_qualification" value="' . $qualification  . '" class="widefat" />';
}

Read more here: Do Ive to create a new function for every meta box field?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , ,

Wordpress related questions and answers: