1

Display Default Sidebar and Widgets

Posted by Edward Caissie on August 13, 2009 in WordPress |

I thought it would be an interesting exercise to provide a solution to displaying the default content of the sidebar that comes with a theme and the content from activated widgets. This is especially useful when using a theme with only one widget area in the sidebar.

The first thing I would strongly recommend is to make a back-up of the sidebar.php file as what I am suggesting would be considered a large or significant edit.

I will be using the code from the Shades theme as it is the simplest to work from, for this tip, and should be easily related to most themes. First, look for the code similar to this, near the top of the sidebar.php file and make note where it is:

<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) : else : ?>

Next, follow the code to near the bottom of the file, and look for a statement very similar if not exactly like this:

<?php endif; ?>

The Shades theme actually has two (2) sidebar widget areas so the code to look for would look similar to this for multiple widget area themes:

<?php endif; ?>
<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?><?php endif; ?>

Make sure to note the code and area between the “dynamic sidebar” line and its matching “endif” line above, in the case of the Shades theme it would be the first instance of the “endif” statement as shown above.

Now, the BIG edit: cut and paste all the code between the two statements you noted above and place it either directly below the “endif” statement; or, directly above the “dynamic sidebar” statement, depending on how you want your sidebar default and widget content to display. If you use “copy” it will display the sidebar default twice until you activate a widget.

Take a look at your blog … if you had no widgets activated before the edit, then you should not notice anything different. Try activating a widget or two and you should see them appear either above, or below, the “default” sidebar content, again depending on where you moved the default sidebar code to.

Feel free to contact us if you need help making these edits to the theme you are using.

Tags: , ,

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2009-2017 BuyNowShop All rights reserved.
This site is using the Custom Child-Theme, v1.0.3, on top of
the Parent-Theme Desk Mess Mirrored, v2.5, from BuyNowShop.com