Custom Sidebars in WordPress

Tualatin Farmers Market has a WordPress site the uses a sidebar for searching, hours and sponsors:

This week they asked if the page for Concerts could be changed so that it didn’t show the sponsors:

I remembered that our theme used a file called sidebar.php and then I added a statement to check for the page name and then alter what posts should be searched using query_posts:

The “if” statement uses: is_page(“Concerts”)

If this page is for Concerts then use: category_name=sidebar_no_sponsors

Other pages use a category_name=sidebar

The client can now login to WordPress and update how the sidebar should look:

The advantage of using this approach is that the client can just use the WYSIWYG editor in WordPress to update how the two different versions of the sidebar should look.

Leave a Reply