WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

in the book professional wordpress, they use something like

$options = array(
    'classname' => 'pp_widget',
    'description' => '...'
$this->WP_Widget('pp_widget', ..., $options);

but in most tutorials

$this->WP_Widget(false, ...

is used. i wonder is there a reason to specify the $id_base param? i see that if i dont, an id will be generated. also, is there any need to specify the classname option?

on a side note, i asked a related question on stack overflow: PHP: parent::somefunction or $this->somefunction if someone got an answer let me know :)

share|improve this question
up vote 1 down vote accepted

The reason is simply customization (these values end up in widget's HTML markup). If someone needs to change this stuff (for example to be compatible with some script without adding wrapper layers) the option is there.

As for methods calling - parent:: explicitly calls method from parent class, $this-> calls method from current class. Since widgets do not redefine WP_Widget method there is no practical difference.

share|improve this answer
thanks for clearing things up. – Jiew Meng Sep 13 '10 at 7:05

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.