Creating metaboxes in loop
-
Hello, I want to create metaboxes in foreach loop. The requirement is, I have an array of custom post types and I want to run a loop to add metaboxes for the post types that are as a key in an array.
So far I have developed much of the requirement but now I am stuck in the part where callback function insideadd_meta_box()
is to be called. I have usedcall_user_func_array
to call the callback function and pass the$key
as an argument but it is returning error and its not working. Below is my code:function rttk_create_boxes(){ $myarray = $this->rttk_get_posttype_array(); foreach ($myarray as $key => $value) { // echo "key--".$key; // $arr[] = ''; // $arr[] = $key; $key = (array)$key; add_meta_box( 'rttk_'.end($key).'_id', __( 'Details', 'rara-theme-toolkit-pro' ), //array($this,'rttk_testimonials_metabox_callback',$key), call_user_func_array(array( $this, 'rttk_testimonials_metabox_callback'),$key ), $key, 'side', 'high' ); } } // testimonials template form public function rttk_testimonials_metabox_callback($key){ // $myarray = $this->rttk_get_posttype_array(); // foreach ($myarray as $key => $value) { include RTTKPRO_BASE_PATH.'/includes/meta-parts/rttk-'.$key.'-template.php'; // } }
Any help would be highly appreciated.
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Creating metaboxes in loop’ is closed to new replies.