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

Is there a way I can make text widgets accept PHP? Perhaps something I can add in to functions.php? I'm redesigning my site, and I was wondering why I didn't use widgets at all in my current design, but then I realized it was because I use a lot of PHP in there.

For example, one of the "widgets" is a tabbed content area, so I've got the HTML and JavaScript shell for the tabs, but then inside the tabs, I've got PHP calls for the most popular posts, the most recent posts, and the most recent comments. I can't do that with existing widgets.

Obviously I could use a plugin, but I'm trying to go light on plugins where possible. Is there something I can just add to functions.php?

share|improve this question
up vote 3 down vote accepted

PHP in text widgets involves using eval(), which is evil.

If you know PHP, stick with static sidebars.

share|improve this answer
That's what I was thinking, but everyone makes it seems like if a theme isn't widget-ready, it's outdated. I have no problems with it though if it's currently the best way to go for what I need to do. Thanks! – Chris May 30 '11 at 20:13

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.