Hi ---
I'm trying to make some modifications to my theme's archives template page and have run into a roadblock. I want to have the ability to make certain sections of the template to be different using conditional tags based up the category id.
For example, you'll see a div (<div id="similar" class="rightcol">) below that includes the text EXTRA SPACE. I want to be able to use this area for different text/images depending on the category.
I'm not very fluent in PHP, so I'd definitely appreciate any help!
Here's the code:
<?php include (TEMPLATEPATH . '/header.php'); ?>
<div id="content">
<?php /* If this is a category archive */ if (is_category()) { ?>
<h2 class="blocktitle"><span><?php echo single_cat_title(); ?></span><a href="<?php echo $feedURL; ?>" class="ico-rss"><img src="<?php bloginfo('template_directory'); ?>/images/feed.png" alt="RSS: News Maker" /></a></h2>
<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
<h2 class="blocktitle"><span>Archive for <?php the_time('F jS, Y'); ?></span><a href="<?php echo $feedURL; ?>" class="ico-rss"><img src="<?php bloginfo('template_directory'); ?>/images/feed.png" alt="RSS: News Maker" /></a></h2>
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
<h2 class="blocktitle"><span>Archive for <?php the_time('F, Y'); ?></span><a href="<?php echo $feedURL; ?>" class="ico-rss"><img src="<?php bloginfo('template_directory'); ?>/images/feed.png" alt="RSS: News Maker" /></a></h2>
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<h2 class="blocktitle"><span>Archive for <?php the_time('Y'); ?></span><a href="<?php echo $feedURL; ?>" class="ico-rss"><img src="<?php bloginfo('template_directory'); ?>/images/feed.png" alt="RSS: News Maker" /></a></h2>
<?php /* If this is an author archive */ } elseif (is_author()) { ?>
<h2 class="blocktitle"><span>Author Archive</span><a href="<?php echo $feedURL; ?>" class="ico-rss"><img src="<?php bloginfo('template_directory'); ?>/images/feed.png" alt="RSS: News Maker" /></a></h2>
<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
<h2 class="blocktitle"><span>Blog Archives</span><a href="<?php echo $feedURL; ?>" class="ico-rss"><img src="<?php bloginfo('template_directory'); ?>/images/feed.png" alt="RSS: News Maker" /></a></h2>
<!--do not delete-->
<?php } ?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if (($paged == 1) && (is_category())) { //if this is page 1, then use the same layout as the homepage and the special archive sidebar
?>
<div id="lastpost" class="leftcol">
<?php
$lastPost = new WP_Query();
$lastPost->query($query_string . '&showposts=1&paged=1');
while ( $lastPost->have_posts() ) : $lastPost->the_post();
?>
<?php if(get_post_meta($post->ID, "image", $single = true) != "") : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "image", $single = true); ?>&w=450&h=300&zc=1&q=95" alt="<?php the_title(); ?>" id="post-image" /></a>
<?php endif; ?>
<div class="snippet leftcol">
<h2 class="title"><a href="<?php the_permalink(); ?>" title="<?php the_title() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<p class="meta">Posted on <?php the_time('F j, Y'); ?> in: <?php the_category(', '); ?></p>
<div class="excerpt"><?php the_excerpt(); ?></div>
<p class="readmore"><a href="<?php the_permalink() ?>">more</a></p>
</div>
<div id="similar" class="rightcol">
<h3>EXTRA SPACE</h3>
Use this space for something useful </div>
<?php endwhile ?>
</div>
<div id="latestposts" class="rightcol">
<?php
$latestPosts = new WP_Query();
$latestPosts->query($query_string . '&showposts=4&offset=1');
while ( $latestPosts->have_posts() ) : $latestPosts->the_post();
?>
<div class="snippet">
<?php if(get_post_meta($post->ID, "image", $single = true) != "") : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "image", $single = true); ?>&w=160&h=100&zc=1&q=95" alt="<?php the_title(); ?>" class="alignleft" /></a>
<?php endif; ?>
<h3 class="title"><a href="<?php the_permalink() ?>" title="<?php the_title() ?>" rel="bookmark"><?php the_title() ?></a></h3>
<div class="excerpt"><?php the_excerpt(); ?></div>
</div><!-- .snippet -->
<?php endwhile ?>
</div>
<?php include (TEMPLATEPATH . '/featured.php'); ?>
<div id="archive">
<h2 class="blocktitle"><span>Archives</span></h2>
<div id="archive-listing" class="leftcol">
<?php
$morePosts = new WP_Query();
$morePosts->query($query_string . '&showposts=5&offset=5&paged=' . $paged);
while ( $morePosts->have_posts() ) : $morePosts->the_post();
?>
<div class="snippet">
<?php if(get_post_meta($post->ID, "image", $single = true) != "") : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "image", $single = true); ?>&w=120&h=80&zc=1&q=95" alt="<?php the_title(); ?>" class="alignleft" /></a>
<?php endif; ?>
<h3 class="title"><a href="<?php the_permalink() ?>" title="<?php the_title() ?>" rel="bookmark"><?php the_title() ?></a></h3>
<p class="meta">Posted on <?php the_time('F j, Y'); ?> in: <?php the_category(', '); ?></p>
<div class="excerpt"><?php the_excerpt(); ?></div>
</div><!-- .post -->
<?php endwhile; ?>
<div class="navigation">
<div class="navleft"><?php previous_posts_link('<img src="' . get_bloginfo(template_url) . '/images/btn_prev.png" alt="Prev" />', '0') ?></div>
<div class="navright"><?php next_posts_link('<img src="' . get_bloginfo(template_url) . '/images/btn_next.png" alt="Next" />', '0') ?></div>
</div>
</div>
<?php include (TEMPLATEPATH . '/sidebar_category.php'); ?>
</div>
<?php } else { //if this is not page 1, then use the archive layout ?>
<div id="archive-listing" class="leftcol">
<?php
while ( have_posts() ) : the_post();
?>
<div class="snippet">
<?php if(get_post_meta($post->ID, "image", $single = true) != "") : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php bloginfo('template_directory'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "image", $single = true); ?>&w=120&h=80&zc=1&q=95" alt="<?php the_title(); ?>" class="alignleft" /></a>
<?php endif; ?>
<h3 class="title"><a href="<?php the_permalink() ?>" title="<?php the_title() ?>" rel="bookmark"><?php the_title() ?></a></h3>
<p class="meta">Posted on <?php the_time('F j, Y'); ?> in: <?php the_category(', '); ?></p>
<div class="excerpt"><?php the_excerpt(); ?></div>
</div><!-- .post -->
<?php endwhile; ?>
<div class="navigation">
<div class="navleft"><?php previous_posts_link('<img src="' . get_bloginfo(template_url) . '/images/btn_prev.png" alt="Prev" />', '0') ?></div>
<div class="navright"><?php next_posts_link('<img src="' . get_bloginfo(template_url) . '/images/btn_next.png" alt="Next" />', '0') ?></div>
</div>
</div>
<?php get_sidebar() ?>
<?php } ?>
</div><!-- #content -->
<?php get_footer() ?>
Thanks so much for the help! Feel free to let me know if you need more details.