My custom post-type has custom meta-box with input
field and wp_editor
, below the code:
<div class="inside">
<div>
<label>Title</label>
<input type="text" name="title[]">
</div>
<div>
<label>Type</label>
<input type="text" name="type[]">
</div>
<div>
<label>Content</label>
'.wp_editor($content, 'text', array(
'wpautop' => true,
'media_buttons' => false,
'textarea_rows' => 5
)
).'
</div>
</div>
wp_editor
is on top & out of the .inside
div.
How can I have the wp_editor
in the .inside
div below the Content label?
Use the ob_start() and ob_get_contents().
There are two other functions you typically pair it with: ob_get_contents(), which basically gives you whatever has been "saved" to the buffer since it was turned on with ob_start(), and then ob_end_clean() or ob_flush()
Attached output.
Code.
ob_start();
wp_editor($content, 'text', array(
'wpautop' => true,
'media_buttons' => false,
'textarea_rows' => 5
)
);
$output = ob_get_clean();
echo '
<div class="inside">
<div>
<label>Title</label>
<input type="text" name="title[]">
</div>
<div>
<label>Type</label>
<input type="text" name="type[]">
</div>
<div style="clear:both"></div>
<div>
<label>Content</label>
'.$output.'
</div>
</div>';