I’m trying to output a unique widget ID inside my mult-instance widgets. So far the following hasn’t worked. Is there a unique ID and how do I call it?
Thanks.
function widget($args, $instance) {
// outputs the content of the widget
extract( $args );
$widget_id = $instance['widget_id'];
?>
<?php echo $widget_id ; ?>
<?php
}
Thanks.
2 s
You can get the instance ID with echo $this->id;
($this
is the class instance)
The only time you can’t get this id is from the form()
function, right after you just dropped the widget (here’s the reason why)