Different sidebar content on different pages

January 26th, 2008

Wordpress: Unique sidebar content on different pages.

Grab the code and dash, or stick around and read the ramble.

Copy your current sidebar, make modifications, add stuff, rename and save as sidebar2.php

The code

In the page you wish to call sidebar2.php simply replace

<?php get_sidebar(); ?>

with

<?php include ('sidebar2.php'); ?>


The long winded ramble

You have your blog up and running, out of the box or a manipulated theme, most likely you will have a sidebar.
Usually here you have links to recent posts, categories, friends and post/comment feeds as standard.
You can add advertising, google ads/ affiliate ads whatever and a variety of other plugins.
The thing is because of the wordpress template system these items will be the same on each page.
The simple solution above allows you to call a different sidebar to a different page.

Go to your dashboard - Presentation - Theme editor and select sidebar.php, copy, modify save as sidebar2.php and FTP the file to the correct place on your allocated server. Eg.
/oikofugic.com/blog/wp-content/themes/evolution, and drop it in there. You should see sidebar.php in the file list, so you will know if you are in the correct location.
Then if it’s your ‘about me’ page, or ‘contact page’ as described above just replace the call for sidebar with a call for sidebar2.
Now that is out of the way the possibilities are endless, you can obviously create as many templates as you wish. Have fun.. Enjoy.

Related posts

    Category template customization
    Template plan: design your own theme

    Entry Filed under: WordPress

Leave a Comment

Required

Required, hidden



Trackback this post  |  Subscribe to the comments via RSS Feed