Displaying unique sidebar for Archives
-
You’ll see on all my main pages, on the left hand side there is the title of the page and a mini description on the graphic of a noticeboard. For example: Big Blogs
“You’re at my blog main page. Here you can follow my journey as it happens and view all archived posts to follow the journey so far.”I would like to feature a different one on each of my archives page. i.e. relate the sidebar to a unique post (which I can edit on the backend)
For example: http://www.thebreadcrumbtrail.org/archives/category/travel-australiaI have tried adding
if ( is_archive ()) { ?> <?php $post_id = 39;
$queried_post = get_post($post_id); echo $queried_post->post_content;?> <?php } ?>to my sidebar.php, but it did not work.
I have however noticed, that I have one archive.php file, yet my posts are filed under “archives” e.g. http://www.thebreadcrumbtrail.org/archives/date/2009/12
Here is my sidebar .php:
<?php /* Local File */ ?> <!-- sidebar start --> <div id="sidebar"> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <div class="intro"> <?php if (is_page('home')) { ?> <?php $post_id = 11; $queried_post = get_post($post_id); echo $queried_post->post_content;?> <?php } ?> <?php if (is_home()) { ?> <?php $post_id = 19; $queried_post = get_post($post_id); echo $queried_post->post_content;?> <?php } ?> <?php if (is_page('Trails')) { ?> <?php $post_id = 25; $queried_post = get_post($post_id); echo $queried_post->post_content;?> <?php } ?> <?php if (is_page('ESE Travel')) { ?> <?php $post_id = 31; $queried_post = get_post($post_id); echo $queried_post->post_content;?> <?php } ?> <?php if (is_page('Gallery')) { ?> <?php $post_id = 36; $queried_post = get_post($post_id); echo $queried_post->post_content;?> <?php } ?> <?php if (is_page('Crumbs About Us')) { ?> <?php $post_id = 5; $queried_post = get_post($post_id); echo $queried_post->post_content;?> <?php } ?> <?php if (is_page('Links')) { ?> <?php $post_id = 39; $queried_post = get_post($post_id); echo $queried_post->post_content;?> <?php } ?> if ( is_page('archives')) { ?> <?php $post_id = 39; $queried_post = get_post($post_id); echo $queried_post->post_content;?> <?php } ?> <p> </p> <p> </p> <p> </p> <p> </p> </div> <div id="sidebar_top"></div> <ul> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Left Sidebar') ) : ?> <li> <h3>Categories</h3> <ul> <?php wp_list_cats('sort_column=name&optioncount=0&hierarchical=0'); ?> </ul> </li> <li> <h3>Archives</h3> <ul> <div id="archives"> <select name="archive-dropdown" onChange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo attribute_escape(__('Select Month')); ?></option> <?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select> </div> </ul> </li> <li> <h3>Meta</h3> <ul> <?php wp_register(); ?> <li><?php wp_loginout(); ?></li> <li><a href="http://validator.w3.org/check/referer">Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a></li> <li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li> <?php wp_meta(); ?> </ul> </li> <?php endif; ?> </ul> </div> <!-- sidebar end -->Any ideas?
Thanks in advance
James
The topic ‘Displaying unique sidebar for Archives’ is closed to new replies.