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

First hope you will take a look example widget http://pastebin.com/2cL7BmgF

There have male and female option. Let say I select male and I want add male.css to wp_head

When I put something like this into the code it's not working.

function load_face() {
  wp_enqueue_style('style', WP_PLUGIN_URL . '/sample/'.$sex.'.css', null, null, 'screen');

Let me know what is the correct code to archive my goal. :)

share|improve this question
up vote 2 down vote accepted

when calling a function within a class you need to use $this


and you will need to populate the value of $sex

public function load_face($instance) {
  $sex = $instance['sex'];
  wp_enqueue_style('style', WP_PLUGIN_URL . '/sample/'.$sex.'.css', null, null, 'screen');
share|improve this answer
Thanks mate for the explanation but I'm really blur.. grgrgr. I got this Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object Question, actually.. where should I put the code into current plugin? – wow Feb 23 '11 at 9:02
inside the widget class – Bainternet Feb 23 '11 at 9:25
I'm still in the dark. – wow Feb 23 '11 at 11: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.