I'm not sure how to describe this, so sorry if the title isn't correct for this question.
I have a file with a bunch of metaboxes but i'm trying to reduce the duplicate entries. So what I'm trying to do is create a variable containing an array which creates the metabox, then trying to update a variable within this array when I call it later on.
The example below i'm trying to update the $title but have no idea how to achieve this or what it's called to google a solution?
<?php
$metabox = array(
'name' => "{$title}",
'id' => "column_content",
'type' => 'wysiwyg',
'raw' => false,
'options' => array(
'textarea_rows' => 3,
'teeny' => true,
'media_buttons' => false,
),
);
$meta_boxes[] = array(
'id' => 'page_builder',
'title' => 'Metabox Example',
'fields' => array(
// Output the above array here:
$metabox,
),
);
Update
I'm not sure I completely explained how I would like to achive this, I wanted to update the $title for the $metabox within the $meta_boxes array()
<?php
$metabox = array(
'name' => "{$title}",
'id' => "column_content",
'type' => 'wysiwyg',
'raw' => false,
'options' => array(
'textarea_rows' => 3,
'teeny' => true,
'media_buttons' => false,
),
);
$meta_boxes[] = array(
'id' => 'page_builder',
'title' => 'Metabox Example',
'fields' => array(
// Output the above array here and update the title on the fly:
$title = 'NEW TITLE';
$metabox,
),
);
$title? What keeps you from changing that static content within that static array?I have a file with a bunch of metaboxes but i'm trying to reduce the duplicate entriesThat single metabox is repeated through the file in multiple places, I don't want to keep duplicating that in the meta_boxes[] array below. So want to create the single field once and update some simple fields. @NicoHaase