siamesecat
Forum Replies Created
-
Forum: Themes and Templates
In reply to: How To Alphabetize PostsYes, I tried that and the only way I was able to get it to work was by repeating the bit of code before the loop twice. Like this:
<?php // we add this to show all posts in a categoy sorted alphabetically if (!is_category('Soldiers by Unit')) { $posts = query_posts($query_string . '&orderby=title&order=asc&posts_per_page=-1'); } if (!is_category('Soldiers by Surname')) { $posts = query_posts($query_string . '&orderby=title&order=asc&posts_per_page=-1'); } // here comes The Loop! if (have_posts()) : while (have_posts()) : the_post(); ?>
And then the subcategories still did not alphabetize themselves. But now I notice that you have an exclamation mark in your bit of code. When I add that to my code (as above), all my posts alphabetize correctly. However, then there is a problem with the home page. I have the home page set up to display the category “frontpage” only. When I include the exclamation marks in the code above, the frontpage category does not display on my home page but the subcategories are alphabetized. When I remove the exclamation marks, the home page is fine but the subcategories do not display.
Here is the bit of code from the book that I am using to display “frontpage” category posts on the home page:
<?php if (is_home()) { query_posts("category_name='frontpage'"); $homepage= true; } ?>
It seems that it is getting overwritten?