I`m looking for a solution to dispaly posts in alpahbetical order if category is “Glossary” otherwise display the posts in ascending order. When I tried the following code its works perfect for category Glossary,but the order of other posts went wrong.
<?php global $query_string;
if(is_category('Glossary'))
{
query_posts($query_string . "&orderby=title&order=ASC");
while ( have_posts() ) : the_post();
the_title();
endwhile;
}
else{
query_posts($query_string . "&order = ASC"); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php } ?>
Hope someone will help me to solve the problem.
First, I would solve your problem using WPQuery. Best to go there as opposed to query_posts
Second, once you acknowledge and accept that WP Query is your friend for as long as you are within the wonderful world of WP theming, then you have to do as follows to solve your particular pickle:
And that ought to do it. You could optimize the
$args
array a bit as I placed some items on both conditionals, but that can do it for a quick test.