Using Conditional Tags in the Sidebar

Cornerstone is set up to display dynamic content depending on which page or post a visitor is seeing (only if you’re not using widgets). You can make the determination what content you want displayed, and where by rearranging the conditional tags used in sidebar.php.

There’s a small snippet you must put in which looks like this:

<?php // if this is the home page
if ( is_home() ) { ?>
YOUR CONTENT HERE
<?php } ?>

So for example if you wanted Recent Entries to show on all pages outside the blog chronology, you could specifiy each page like this:

<?php // if this is an archive listing, basic Page or error page
if ( is_archive() || is_page() || is_404() || is_search() ) { ?>
<h2>Recent Entries</h2>
<ul><?php get_archives('postbypost', 5); ?></ul>
<?php } ?>

Another example, if you wanted related posts to show up only on single post pages, you could do so like this:

<?php // if this is a single post page
if ( is_single() ) { ?>
<h2>Related Entries</h2>
<ul><?php related_posts(); ?></ul>
<?php } ?>

Note: This assumes you’re using the Related Posts plugin, but I recently discovered one called Similar Posts, which I’ve come to prefer.

There are three sidebar “sections”, so that each one could be individually widgetized. I tried to be very clear in the code comments so you would have no trouble moving things around or switching things out  - but if you get overwhelmed by the lengthy sidebar.php file or using conditionals, give me a shout and I’ll try to help you sort it out. :)