12 Jul 2017

Display a widget title

The following is a snippet of code I used to display a widget with the ID video title after the widget (rather than before the widget).


<?php $sidebar_id = 'video';
$sidebars_widgets = wp_get_sidebars_widgets();
$widget_ids = $sidebars_widgets[$sidebar_id];
foreach( $widget_ids as $id ) {
$wdgtvar = 'widget_'._get_widget_id_base( $id );
$idvar = _get_widget_id_base( $id );
$instance = get_option( $wdgtvar );
$idbs = str_replace( $idvar.'-', '', $id );
} ?>

<section id="video">
<div class="inner">
<div class="container">
<?php dynamic_sidebar( 'video' ); ?>
<?php echo $instance[$idbs]['title']; ?>
</div>
</div>
</section>