Use Widgets in the Sidebar or use the default items
By default BranfordMagazine as well as WyntonMagazine come with an “intelligent” sidebar. I call it “intelligent” because it displays different items based on where you are on the site. Of course you can also use widgets if you feel more comfortable with it.
Widgets or default Items – You decide
Many people prefer to use widgets instead of sticking with the default stuff or put some code inside the sidebar.php file manually. That´s fine since widgets are very handy and usefull and make it easy to move and change things in the sidebar. But you need to be aware of the fact that you can basically just EITHER use widgets OR the default stuff. If you use widgets (even if you just use one single widget) the default items are not being displayed anymore with the exception of some things in BranfordMagazine. BranfordMagazine sidebar is build to have the widgetized area between some hardcoded stuff that will last even if you use widgets. That´s the list of news on the homepage aswell as the RSS and “who writes” links.
Wanna have it all? It´s possible
For most people that´s just fine but what if you want to have both? Of course there is a way to use widgets AND some of the default stuff. Imagine a text widget. You can use a text widget not only to display text but also to key in html or php code. This requires a plugin like exec php to be installed in order to be able to execute code. Once the plugin is installed you can put code in textwidgets and it will act as if it is written into the file. The new custom widgets that where introduced in BranfordMagazine version 5 and WyntonMagazine version 2 are also a great opportunity of adding dynamic content. They provide some of the hardcoded functionality of the sidebar in a flexible widget (such as the “more from this category” list).
An example for hardcoded Stuff in a Textwidget
Let´s say you want to have the latest news block from the homepage of BranfordMagazine but for everything else you want to use widgets. Well put your widgets into the sidebar and put a textwidget on top. Now check out sidebar.php and copy this piece of code into your textwidget:
<li>
<h3>
<?php
// this is where the name of the News (or whatever) category gets printed
wp_list_categories("include=$prinz_lead;&title_li=&style=none"); ?>
</h3>
<?php
// this is where the last five headlines are pulled from the News (or whatever) category but not the first one (offset=1) since this is already displayed as leadarticle.
query_posts("offset=1&cat=$prinz_lead;&showposts=$prinz_sidenewsnumber;");
?>
<ul class="bullets">
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?>
</a></li>
<?php endwhile; ?>
</ul>
</li>
<?php } ?>
You need to change some small things now. You see the variables that are been used by the options page (backend) which do not work in this case (maybe I will find out why and change that).
$prinz_lead
$prinz_sidenewsnumber
For $prinz_lead you put the ID (a number) of the category (your newscategory) and for $prinz_sidenewsnumber you put a number to tell the site how many newsheadlines to display.
That´s how it might look like then:
<li>
<h3>
<?php
// this is where the name of the News (or whatever) category gets printed
wp_list_categories("include=1;&title_li=&style=none"); ?>
</h3>
<?php
// this is where the last five headlines are pulled from the News (or whatever) category but not the first one (offset=1) since this is already displayed as leadarticle.
query_posts("offset=1&cat=1;&showposts=5;");
?>
<ul class="bullets">
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?>
</a></li>
<?php endwhile; ?>
</ul>
</li>
<?php } ?>
In this case “1″ is the category ID and “5″ the number of posts (headlines) to display.
That´s it. Now you can use this little workaround for any item from the default sidebar that you like to use together with widgets.