• Resolved blizcreak

    (@blizcreak)


    I have hunted through google, and tried different plugins, but still can’t achieve what I am aiming to do.

    The goal is simple. When I display a Category page, I want the posts to be displayed in chronological order (ie oldest at the top) which is the reverse of the defail order.

    How do I do that without changing the order of other pages – eg the home page or the archive page?

    I am using twentyfourteen, and the category.php has this code:

    <?php if ( have_posts() ) : ?>
    
    			<header class="archive-header">
    				<h1 class="archive-title"><span style='color:gray'>DDDB Case Reports: </span><?php printf( __( ' %s', 'twentyfourteen' ), single_cat_title( '', false ) ); ?></h1>
    
    				<?php
    					// Show an optional term description.
    					$term_description = term_description();
    					if ( ! empty( $term_description ) ) :
    						printf( '<div class="taxonomy-description">%s</div>', $term_description );
    					endif;
    				?>
    			</header><!-- .archive-header -->
    
    			<?php
    					// Start the Loop.
    					while ( have_posts() ) : the_post();

    Do I put something in there to reverse the order, and still have it paginate correctly?

    Thanks!

    Noel

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter blizcreak

    (@blizcreak)

    Solved.

    I modified the code from the default_sort_ascend plugin to the following, and then put it in the functions.php file:

    <?php
    
    function default_sort_ascend($t) {  
    
    		 $q = $t->query_vars;
    		 if ( !empty($q['category_name'])) {
    			 if ( empty($q['order']) || ((strtoupper($q['order']) != 'DESC') && (strtoupper($q['order']) != 'ASC')) )
    				  $q['order'] = 'ASC';
    			 $t->query_vars = $q;
    		}
    }
     add_action('pre_get_posts', 'default_sort_ascend');
    ?>

    hey bilzcreak i used your HTML code and my site went BLANK – thanks for nothing

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List posts in chronological order in Category archive’ is closed to new replies.