• Hey there. This is my second wordpress theme but I’m converting somebody else’s HTML into a wp page. I’ve almost got everything sorted but I’m having an issue. In my sidebar.php, I have at the bottom

    <!--Sort By Date-->
    
    <h2 class="sidebar-title">Sort By Date</h2>
    <ul class="archive-list">
    <?php wp_get_archives( 'type=monthly' ); ?>
    </ul>

    and archive.php looks as follows

    <?php get_header(); ?>
    
    <div id="content"><!--Begin #content-->
    
    <div id="main"><!--Begin #main-->
    <div id="main2"><!--Begin #main2-->
    
    		<?php if (have_posts()) : ?>
    
     			<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    
    			<?php /* If this is a category archive */ if (is_category()) { ?>
    				<h2>Archive for the ‘<?php single_cat_title(); ?>’ Category</h2>
    
    			<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
    				<h2>Posts Tagged ‘<?php single_tag_title(); ?>’</h2>
    
    			<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    				<h2>Archive for <?php the_time('F jS, Y'); ?></h2>
    
    			<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    				<h2>Archive for <?php the_time('F, Y'); ?></h2>
    
    			<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    				<h2>Archive for <?php the_time('Y'); ?></h2>
    
    			<?php /* If this is an author archive */ } elseif (is_author()) { ?>
    				<h2>Author Archive</h2>
    
    			<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
    				<h2>Blog Archives</h2>
    
    			<?php } ?>
    
    			<?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>
    
    			<?php while (have_posts()) : the_post(); ?>
    
    				<div <?php post_class() ?>>
    
    					<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    
    					<?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>
    
    					<div class="entry">
    						<?php the_content(); ?>
    					</div>
    
    				</div>
    
    			<?php endwhile; ?>
    
    			<?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>
    
    	<?php else : ?>
    
    		<h2>Nothing found</h2>
    
    	<?php endif; ?>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    My sidebar displays April 2011, which is the month I made some Test posts in. The hyperlink for april, however, is

    https://localhost/soperfect_wp/?m=201104&cat=5

    but the code for this link in the sidebar.php is

    <!--Sort By Date-->
    
    <h2 class="sidebar-title">Sort By Date</h2>
    <ul class="archive-list">
    <?php wp_get_archives( 'type=monthly' ); ?>
    </ul>

    So I don’t know where the page is getting the idea that I want it to generate a link to …/?m=201104&cat=5 instead of …/?m=201104

    Any help would be sincerely appreciated.

  • The topic ‘Having trouble with Sort By Date in sidebar…each month links to Category 5?’ is closed to new replies.