Create Dynamic Sidebars
Thanks for visiting! If you're new here, you may want to subscribe to our RSS feed. This blog posts regular Wordpress news, updates of themes, plugins, ideas, hacks, quick fixes and everything about blogging, especially about Wordpress. Go ahead, subscribe to our feed! You can also receive updates from this blog via email.
Richard Hooper of WP Project.com has published an interesting post which explains how to create dynamic sidebars. As it stands, there is no way to assign widgets to only appear on specific pages of your WordPress Powered blog in the back end. Using Richard’s method, you can create your own sidebar.php file and assign various widgets or plugins to only show up on specific sections of your blog. This is great if you want to display a widget on a SINGLE post template versus the front page.
Richard also adds that
Aside from creating a dynamic sidebar, this approach breaks up your sidebar code into smaller, more manageable chunks.
Perhaps we should coax Richard into turning this into a plugin in which normal users can then assign widgets to appear on certain page templates.
Here is a question I have. You can use this method to assign plugins/widgets to appear on page templates, but outside of hardcoding those templates, can you manually assign widgets to appear on certain pages without having to place PHP code into the page itself. For example, if I have an about page, and I have a contact page, is there a way to assign a widget to show up on the about page but not the contact page, even though they are both on the same page template. Does that sort of granularity and control exist?


(5 votes, average: 4.8 out of 5)











Comments RSS
You might be interested in using my plugin. It is called Core Sidebars and it allows you to assign widgets / sidebar content to specific pages or posts. It has the dynamic sidebar capability that you are possibly looking for. Available at the Wordpress directory .
[Reply] Daniel (1 comments.) — 06/2/2008 @ 9:16 amThe Widget Logic plugin gives every widget an extra control field called “Widget logic” that lets you control when the widget appears.
In the Admin/Design/Widget, all you need to do is type
[Reply] Denis (1 comments.) — 06/2/2008 @ 10:49 amis_page('about')into that extra field of the desired widget.I found a plugin called widget logic which does exactly that, it allows you to control when and how widgets are displayed. Check it out at - http://wordpress.org/extend/plugins/widget-logic/
[Reply] nomad-one (1 comments.) — 06/2/2008 @ 11:11 aminteresting,I’ve implement dynamic sidebars (& widgets) base on wordpress template hierarchy (i.e, single, page, archive) in all my theme.
[Reply] chaoskaizer (1 comments.) — 06/2/2008 @ 11:23 amhere some live example at kakkoi & its POSH too.
You might also want to check out Daiko’ Text Widget as it will let you specify the pages you want it to show the content on. IT also supports PHP code
[Reply] Steven Hodson — 06/2/2008 @ 11:31 amhelps if I remember the URL eh
[Reply] Steven Hodson (2 comments.) — 06/2/2008 @ 11:32 amhttp://www.daikos.net/widgets/daikos-text-widget/
comrade: no i dont thing ‘that sort of granularity and control exist’ yet lol
[Reply] kim (6 comments.) — 06/2/2008 @ 12:07 pmThere’s also Sidebar Modules - http://nybblelabs.org.uk/projects/sidebar-modules/ - which is a replacement of the Widget functionality. It provides fairly granular control.
[Reply] Rick Beckman (13 comments.) — 06/2/2008 @ 5:26 pmThis is exactly what i was looking for, thanx guys
[Reply] Neil (26 comments.) — 06/2/2008 @ 5:33 pmGood news are coming, thanks.
[Reply] Ted Liptak (4 comments.) — 06/2/2008 @ 6:13 pmthanks, this is i’m looking for very long time.
[Reply] palPalani (1 comments.) — 06/2/2008 @ 11:59 pm@ Jeff
There is a simple way to assign widgets to a particular page using conditional tags, refer to Codex. It gets better, you can create much more complex dynamic array funtions with 2.5.x, I have a “how to” with a demo on my site.
[Reply] Sunny (3 comments.) — 06/3/2008 @ 5:25 pmSounds like what my Section Specific Text Widget was born to do
[Reply] Azmeen (14 comments.) — 06/3/2008 @ 7:27 pm[...] Creating Dynamic Sidebars in WordPress [...]
WordPress Weekly Episode 19 | Jeffro2pt0 — 06/6/2008 @ 7:40 amSorry I’m newby on wordpress, could tell me how can I create a dynamic sidebar as simple as we can?
[Reply] Inspirasi bisnis — 06/6/2008 @ 8:40 amAs far as plugins are concerned, there are many that manage this idea in one form or another, as you can see by the comments here.
Personally, I try to avoid plugins wherever possible—which is why I share these simple code hacks as I implement them on WP Project.
Yes, use is_page(’contact’) or is_page(’about’).
Thanks for the support Jeff.
[Reply] Richard H (3 comments.) — 06/8/2008 @ 7:28 amThis is really nice. I’ve seen a couple of complicate quality themes that did this, but I was wondering how to do it for my own these. Thanks
[Reply] Scott Gostyla (1 comments.) — 06/25/2008 @ 7:40 pm