Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress Build a Website with WordPress WordPress Widgets and Custom Menus How to Create Widgetized Areas in WordPress

Susie Broughton
Susie Broughton
2,130 Points

create_widget question

On the create_widget function where it is actually generating the widget I have a question about the parameters passed after.

create_widget("Header", "Uptop", "Displays in the header of the site, above the title")

Now is "Header" the 'name' of the sidebar. Is "Uptop" the 'id' (I thought IDs were all numerical). Which leaves "Displays....title" as the 'description'. Is this correct or am I barking up the wrong tree?

Mod Note Added some forum markdown for clarity :-)

3 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi Susie,

Yes I believe that that is the case. The create_widget function creates the building blocks for a new widget that will appear in the admin area.

Although I'm not seeing create_widget in the WordPress codex so I wonder if that function is deprecated. In any case if you want to look up parameters of a function and see how things work the Codes is a great resource.

Here's a Codex page for adding Widgets to your theme. https://codex.wordpress.org/Widgets_API and a beginner tutorial for adding widgets to your WordPress site. :) http://www.wpbeginner.com/wp-tutorials/how-to-create-a-custom-wordpress-widget/

With 4.8 just being released, they made a major upgrade to the widgets. I would look into that as well.

Susie Broughton
Susie Broughton
2,130 Points

Thanks for the feedback chaps!