WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


function widget($args, $instance) {
// outputs the content of the widget
    extract( $args );
    $widget_id = $instance['widget_id'];    
<?php echo $widget_id ; ?>


share|improve this question
up vote 8 down vote accepted

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)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.