• Hi All,

    I’ve created/copied the following code to create a new archive sidebar for my posts, which works fine:

    <bside>
    <img class="logos" src="<?php bloginfo('template_url'); ?>/images/archive.png" />
    <?php
    $year_prev = null;
    $months = $wpdb->get_results(	"SELECT DISTINCT MONTH( post_date ) AS month ,
    								YEAR( post_date ) AS year,
    								COUNT( id ) as post_count FROM $wpdb->posts
    								WHERE post_status = 'publish' and post_date <= now( )
    								and post_type = 'post'
    								GROUP BY month , year
     							        ORDER BY post_date DESC");
    foreach($months as $month) :
    	$year_current = $month->year;
    	if ($year_current != $year_prev){
    		if ($year_prev != null){?>
    
    </ul>
    
    		<?php } ?>
    
           <h3><?php echo $month->year; ?></h3>
    	<ul class="archive-list">
    	<?php } ?>
    	<li>
    		<a href="<?php bloginfo('url') ?>/<?php echo $month->year; ?>/<?php echo date("m", mktime(0, 0, 0, $month->month, 1, $month->year)) ?>">
    			<span class="archive-month"><?php echo date("F", mktime(0, 0, 0, $month->month, 1, $month->year))?></span>
    			<span class="archive-count"><?php echo $month->post_count; ?></span>
    	</a>
    </li>
    <?php $year_prev = $year_current;
    endforeach; ?>
    </ul>
      </bside>

    This is referenced in my single.php file.

    However, I would like to have a separate sidebar for each category (One for News Posts & one for a Blog) as they will be separate pages.

    I do not have a category.php, etc. only index.php with this code:

    <article>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
         <h1 class="contentheading"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
              <?php the_excerpt() ?>
    <?php endwhile; ?>
    <?php endif; ?>
    </article>
    
    <?php get_sidebar('ArchivePosts'); ?>
    <?php get_footer(); ?>

    Any help/advice on splitting the categories into 2 sidebars would be great. I’m not a code master…….

    Cheers.

Viewing 1 replies (of 1 total)
  • Thread Starter DJCopa

    (@djcopa)

    This is on a localhost, so unable to post URL. I should also add that the top code is ArchivePosts.php.

    Cheers.

Viewing 1 replies (of 1 total)
  • The topic ‘Edit custom ArchiveSiderbar.php to show specific catergory’ is closed to new replies.