Sorting search results by post title
-
Hi!
I need some help to figure out how to display the search results sorted alphabetically (by post title).
I have restricted the search to a custom post type name docs, with this code in searchform.php:
<input type="hidden" name="post_type" value="docs" />
And here’s the code to the loop in search.php:
if(have_posts()): while(have_posts()):the_post();
So far, it works perfectly. But if I add these lines before the loop
global $query_string; query_posts( $query_string . '&orderby=title&order=ASC' );
the search doesn’t work anymore (the ‘not found’ message is displayed).
Any idea why this doesn’t work?
Thanks for your time!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Sorting search results by post title’ is closed to new replies.