I want to add a widget are in the footer so I can add widgets from the widgets area in adminCP. what’s the code for that? thx
I won’t go into the code because there are actually a few ways you can approach this and every theme uses a unique framework, but essentially you need to register a new sidebar and then call it back in the template file…
Regarding the sidebar registration: you may need to register as many as 2, 3, or 4 of them depending on how many widgets you want and how you are styling them – I’ve seen people use one sidebar and “float:left;” each individual widget, or use a separate sidebar for each column of widgets and allow them to stack – it depends on your desgn.
To register sidebars, check out this article:
Once you’ve registered the sidebar, you then you need to call back the sidebar using the dynamic sidebar include in the template file (ie: index.php, or footer.php):
It took me several attempts over the course of an hour the first time I worked on this… but with some trial & error and a little perseverance you’ll do fine
I should also note that if you are using a theme that uses a formal framework (ie: thematic or any of the many others out there), this method will need to adapt to the framework for that theme. I know, this is probably pretty annoying, but essentially you need to identify where the theme’s sidebars are being registered at and work in the same spot. They may also be using some sort of custom dynamic_sidebar callback as well – you’ve just gotta sort out how your theme’s functioning and work within those parameters. If you’re using a Vanilla framework without any custom sidebar code, you can do as you please though.
Also – someone else in the forums may have a better answer for you – I’m just dishing out from my experience. There’s always someone with a better coding method out there though.
Ok, thanks. I’m making my own theme, using the default theme as my foundation (just editing it).
Oh, and where do I register the sidebar? (Keep redistributing in mind)
Oh, and where do I register the sidebar?
Usually in functions.php
Just paste the code in?
Yep – usually you do it in functions.php – I’ve also seen it separated into it’s own file as well (ie: a new file called “widgets.php”), but that’s purely up to you as the author. Themes with lots and lots of add-on functions benefit from separate files (its just easier to read and find what you want), but simple themes benefit from packing everything into functions.php. Good luck!
Ok, thanks. I’ll give that a try