Order Category Posts
-
I’d like to order all the posts listed on my category.php page alphabetically.
Here is the code on my category.php page:
<?php /** * The template for displaying Category Archive pages. */ get_header(); ?> <?php global $q_config; ?> <div id="product_gallery" role="main"> <?php while ( have_posts() ) : the_post(); ?> <?php //This checks what language qTranslate has selected and returns the appropriate ShortDesc if (ppqtrans_getLanguage() =="en") { $key = "byline_en"; $description = get_post_meta($post->ID, $key, true); } if (ppqtrans_getLanguage() =="fr") { $key = "byline_fr"; $description = get_post_meta($post->ID, $key, true); } ?> <div class="product_thumbnail"> <a href="<?php the_permalink() ?>"> <?php //the_post_thumbnail grabs the post's "featured image" this feature has added theme support in the child theme functions.php ?> <?php the_post_thumbnail('thumbnail', array('class' => 'thumbnail')); ?> </a> <?php //This piece of code figures out the corrosponding post_title of the featured image ?> <h1 class="post_caption"><?php the_title(); ?></h1> <p><?php echo $description; ?></p> </div> <!-- product_thumbnail --> <?php endwhile; // end of the loop. ?> <div class="clear"></div> </div><!-- #content --> <?php get_footer(); ?>What do you think the best way to go about that would be?
Viewing 1 replies (of 1 total)
-
Hi bluedrag. Take a look at the pre_get_posts() action:
https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_postsSome examples:
http://devotepress.com/tutorials-hacks/wordpress-coding/when-to-use-pre_get_posts-in-wordpress/
Viewing 1 replies (of 1 total)
The topic ‘Order Category Posts’ is closed to new replies.