features category image instructions category image Page/Post Option – Left, Right or No Sidebar

Posted on October 26, 2009 and last modified on October 27th, 2009.

There are several means of changing the sidebar content within this theme and many of them are discussed at length here and here. However, the purpose of this post is to explain the positioning of the sidebar and which sidebar to include on any given page or post.

The names of the varying sidebar are as follows:

  • sidebar.php
  • sidebar_all.php
  • sidebar_gallery.php
  • sidebar_left.php
  • sidebar_short.php

Each one of these is slightly different and they are called from within the page templates on the second to last line of code. Here is an example of the gallery page [page_gallery.php] calling the sidebar-gallery.php

<?php include('sidebar-gallery.php'); ?>

A note here for those who may make some more sidebars of their own. I found that using underscores caused me problems later when I used the the next method to call different sidebars for different posts so make sure you use a hyphen as opposed to an underscore, i.e. sidebar-gallery and NOT sidebar_gallery.

In posts, by default the sidebar will always be sidebar.php which includes all of the sidebar elements. However you can change which sidebar displays by adding a simple custom field aptly named ‘sidebar‘ and then using the name of the sidebar as the value. For example, to call the same sidebar within a post that is used on the Gallery page, all you need to do is add sidebar to the custom field name and then add ‘gallery‘ to the value. Update and save and it’s all done.

It is done on this post just to show you the result.

Related Posts:

My Tweets Page
Post Word Count and Total Posts
Author’s Details in Every Post
Set Individual Styles for Specific Posts
Set Specific Stylesheets for Pages

About the author

James has added 29 posts to this site so far...

Founder and co-admin at FreshlyPressed, James also runs and maintains many, many other sites including JamesICT which is very much focussed on WordPress and all of its little idiosyncrasies. He now lives in Brighton, England with his fiancée and writes novels in his spare time. His latest work, 'Procrastination Expectancies' is due out later this year - or maybe the year after that! [more...]

Other posts by James

Trackbacks/Pingbacks

  1. [...] This briefly describes the manner in which the sidebar elements work, now let’s take a look at how the sidebars within each page can be adjusted to suit each page’s individual style. Go look now… [...]

  2. [...] WIDGET READY in TWO SIDEBARS – RIGHT MENU and FOOTER [...]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>