I can get a list of sidebars by going through wp_registered_sidebars
<?php foreach ( $GLOBALS['wp_registered_sidebars'] as $sidebar ) { ?>
<input value="<?php echo ucwords( $sidebar['id'] ); ?>">
<?php echo ucwords( $sidebar['name'] ); ?>
<?php } ?>
And I can output the sidebar with
<?php echo dynamic_sidebar( ucwords( $sidebar['id'] )); ?>
But I need to output the HTML content out.
I am trying to insert the sidebar in a menu (megamenu), and I am following this post on how to get the metabox appear in my Menus page. I've done it all, I can get the name, id of the sidebar, everything. It's just when I try to add HTML content in my description field of the menu, I don't know how. If I put the dynamic_sidebar I'll get the actuall sidebar in my menus page, and that's not what I want.
So any help is appreciated.
Is it possible to do it with ob_start()
function?
EDIT
I tried with:
<?php
ob_start();
dynamic_sidebar($sidebar['id']);
$sidebar_html = ob_get_contents();
ob_end_clean();
?>
But when I echo that variable inside the hidden input field
<input type="hidden" class="menu-item-description" name="menu-item[-1][menu-item-description]" value="<?php echo $sidebar_html; ?>">
I still get the html out. I just need it as a text html that won't be 'executed'.
Ok,
htmlentities()
did it