WordPress.org

Ready to get started?Download WordPress

Forums

Reserve post order on a category.php page (3 posts)

  1. bradyjfrey
    Member
    Posted 6 years ago #

    Does anyone know how to reverse the post order on a category or archive page? The typical:
    <?php query_posts('order=DESC'); ?>

    Works in the sense it adjusts the post order, but it also resets the loop so that ALL posts are called, just just that specific category. The intention is for me to have a category.php page that showcases just that categories posts, and allows me to adjust the order as intended. Thank you!

  2. Chris_K
    Member
    Posted 6 years ago #

    What page are you editing?

    If you look at Template_Hierarchy, you'll see that you have a variety of choices for Category display. If you only want to reverse one category, create a new category-x.php file (where x is the category ID) and modify just that one.

    Does that make sense? Or am I off in the weeds?

  3. bradyjfrey
    Member
    Posted 6 years ago #

    Hmmm, I'll take a look at that, but here's what I'm after - on this page, you'll see the photos as posts, I want to put them in the reverse order - normally I'd apply a query to the loop, but doing so removes the individual category filter and shows ALL posts, just with that query. The site example:
    http://jeanand.russjang.com/category/bride-preparation/

    Offending code:

    <?php get_header(); ?>
    
    <h2>You are viewing the <strong>"<?php echo single_cat_title(); ?>"</strong> Gallery</h2>
    <?php get_sidebar(); ?>
    
    	<dl id="sub_indexg">
    		<dt>Pick A Photo</dt>
    		<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    		<?php if ($post->image): ?>
    		<dd><a href="<?php the_permalink(); ?>" title="View the full picture of '<?php the_title(); ?>'">
    		<?php if (!is_null($image = YapbImage::getInstanceFromDb($post->ID))): ?>
    		<img src="<?php echo $image->getThumbnailHref(array('w=90')) ?>" width="90" alt="<?php the_title(); ?>" />
    		<?php endif ?></a></dd>
    		<?php endif; ?>
    		<?php endwhile; ?>
    	</dl>
    
    	<?php else : ?>
    
    		<h2>Not Found</h2>
    		Sorry, but you are looking for something that isn't here.
    
    	<?php endif; ?>
    
    <?php get_footer(); ?>

    Ignore the Photoblog only code, it's not relevant in this context.

    If I query:

    <?php get_header(); ?>
    
    <h2>You are viewing the <strong>"<?php echo single_cat_title(); ?>"</strong> Gallery</h2>
    <?php get_sidebar(); ?>
    
    	<dl id="sub_indexg">
    		<dt>Pick A Photo</dt>
    		<?php query_posts('order=DESC'); ?>
    		<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    		<?php if ($post->image): ?>
    		<dd><a href="<?php the_permalink(); ?>" title="View the full picture of '<?php the_title(); ?>'">
    		<?php if (!is_null($image = YapbImage::getInstanceFromDb($post->ID))): ?>
    		<img src="<?php echo $image->getThumbnailHref(array('w=90')) ?>" width="90" alt="<?php the_title(); ?>" />
    		<?php endif ?></a></dd>
    		<?php endif; ?>
    		<?php endwhile; ?>
    	</dl>
    
    	<?php else : ?>
    
    		<h2>Not Found</h2>
    		Sorry, but you are looking for something that isn't here.
    
    	<?php endif; ?>
    
    <?php get_footer(); ?>

    I maybe calling that code wrong and it shouldn't just be a simple loop query? This is a category.php page code, btw, same problem if I apply a query to the archive.php page though, which made me think I'm either using the wrong call or this isn't currently possible. Thanks for the help:)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.