Its because you are assigning your last array element to your class properties post_type
,unicname
,headline
,fieldDisc
Since the input is an array you are overriding the class properties again and again, only last array element is saved there(post_type
,unicname
,headline
,fieldDisc
).
So what I would suggest is either store the whole array in one property or make each property an array so that they get room for holding multiple values
public function __construct( $array ) {
global $post;
$this->metabox_array = $array;
add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
add_action( 'save_post', array( $this, 'save' ), 1, 2);
}
//here a goes other methods that render and save metaboxes...
public function add_meta_box() {
//looping over all input array
foreach ( $this->metabox_array as $metabox ) {
add_meta_box(
$metabox['unicname']
,$metabox['headline']
,array( $this, 'render_meta_box_content' )
,$metabox['post_type']
,'advanced'
,'high'
);
}
}
Your render_meta_box_content
should have content accordingly, by looping over the array.