WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] archive.php showing posts alphabetically (2 posts)

  1. grishart
    Member
    Posted 2 years ago #

    Hi All

    I want to show the search results alphabetically on my archive.php page as I have it set on my index page.

    I used the following code on my index page.

    <?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(); ?>

    but when I replace the

    <?php while (have_posts()) : the_post(); ?>
    code on the archive page it shows nothing.

    can anyone help?

    thanks for your time.

  2. grishart
    Member
    Posted 2 years ago #

    Hi Have just found the answer.

    before the loop

    <?php while (have_posts()) : the_post(); ?>
    put

    <?php
    // we add this, to show all posts in our
    // Glossary sorted alphabetically
    $posts = query_posts($query_string .
    '&orderby=title&order=asc&posts_per_page=-1'); ?>

    It worked a treat!

Topic Closed

This topic has been closed to new replies.

About this Topic