Search Results in Alphabetical or Relevant Order? (8 posts)

  1. jsuko
    Posted 10 years ago #

    I hope this isn't in the forums somewhere else, but I've been wondering if someone could help me with getting my search results to display in alphabetical (title) and not chronological order. What or how can this be done?

    Also, is there a way to search based on relevance?

    Any help is appreciated, as I'm getting pretty frustrated. Thanks!

  2. Kafkaesqui

    Posted 10 years ago #

    If you have a search.php template with your theme, insert this in it just above The Loop:

    <?php query_posts('orderby=title&order=ASC'); ?>

    If you don't have a search.php, you can copy the theme's archive.php (or if *that* is not available, index.php) for it. Alternatively, you could use the following in archive.php/index.php:

    <?php if(is_search()) {
    } ?>

    More info on query_posts():

    "Also, is there a way to search based on relevance?"

    Plugin you may want to check out:

  3. jsuko
    Posted 10 years ago #

    thanks for the direction!

  4. Beel
    Posted 10 years ago #

    Nice Kafka, though I don't understand the relevance. If I am searching for something on "blah", the title would be irrelevant. Just because it starts with an "A" doesn't mean it contains the information for which I am looking ;-).

  5. snoogly
    Posted 10 years ago #


    <?php query_posts('orderby=title&order=ASC'); ?>

    does get the search results in alphabetical order, but the navigation to next and previous search results pages no longer works. I can't see more than the first page of search results.

  6. James Huff
    Support Representative
    Posted 10 years ago #

  7. snoogly
    Posted 10 years ago #

    Is there any documentation for that plugin? I can't find any ways to configure it.

  8. snoogly
    Posted 10 years ago #

    I tried adding this to search.php

    // we add this, to show *all* posts sorted
    // alphabetically by title
    $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(); ?>

    (found at: http://codex.wordpress.org/Alphabetizing_Posts) but I get the same non-functioning next and previous buttons. Does this indicate that something is broken?

Topic Closed

This topic has been closed to new replies.

About this Topic