Support » Themes and Templates » orderby=title not working.

Viewing 10 replies - 1 through 10 (of 10 total)
  • esmi


    Forum Moderator

    Have you tried placing:
    <?php query_posts('orderby=title&order=ASC'); ?>
    just before The Loop?

    I made the mistake of putting the query inside the loop. However, I placed it outside of the loop and although it ordered the posts differently, they are still not in alphabetical order… any idea why this is happening?

    <?php query_posts(‘cat=&orderby=title&order=ASC’); ?>
    <?php if ( have_posts() ) : while (have_posts()) : the_post(); ?>

    <!–post title as a link–>
    <div style=”width: 660px; float: left; margin: 10px 0px 0px 0px; display: block;”><hr />
    <div id=”postthumb”>

    <?php $postimageurl = get_post_meta($post->ID, ‘thumb’, true); if ($postimageurl) { ?>

    <div class=”postimage”><img src=”<?php echo $postimageurl; ?>” alt=”” width=”133″ height=”100″ />
    <?php wp_gdsr_render_article(); ?>
    #respond” style=”font-size:.9em;”>Submit a Review
    #comments”>Read Reviews</div>
    <?php } ?></div>

    <div style=”float:left; display:block; width:475px;”>



    Forum Moderator

    what did esmi suggest:

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

    and what did you put in:

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

    could it be that the extra cat=& is stopping it from working?

    I already tried that already. When I take out the ‘cat=’ it has the same result.

    Try replacing orderby with order?

    Also, if the above doesn’t work, try replacing title with name, using orderby or order

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Where exactly are you putting this query_posts bit?

    I took a look at your site, and it seems broken a bit. I suspect because of your query_posts being in index.php. I assume you only want that category to be in alphabetical order or something?

    Because your index page seems badly broken, and your category page seems fine (albeit in the wrong order), then I suspect you really want to be putting the query_posts into the category.php file instead of the index.php file.

    I also suspect that you want to keep pagination working, in which case you’ll need to add the query string variable.

    Like so:
    <?php query_posts($query_string.'&orderby=title&order=ASC'); ?>

    If not, then try this: Tell us what you want to do, let us tell you how to do it. That usually works better.

    Finally got it working. The issue had to do with a few misplaced and missing query tags.

    Otto, do you still see pieces that are broken? If so, can you point them out to me? I needed separate queries on the index.php and the category template. Things are working now, but if you see that something is still broken, please point it out to me so I can fix it.

    Thanks to everyone for their help!

    Oh, I forgot to also thank you for the tip on keeping the pagination working on the category page. Thanks! 🙂

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Your home page is still broken, the older posts and newer posts links don’t seem to do anything. Pagination issue in your query?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘orderby=title not working.’ is closed to new replies.