WordPress.org

Ready to get started?Download WordPress

Forums

orderby=title not working. (11 posts)

  1. mandawahoo
    Member
    Posted 5 years ago #

    I am trying to get posts to list by their post title - date is irrelevant. Unfortunately its not working and continues to post things by the date they were drafted (see where Edelman Leather falls on the page linked below). I have tried a few different things with the query, but all return the same result. I'd really appreciate help with this.

    Thank you!

    http://gibsondesignmanagement.com/reviewcenter/category/designcenters/denver/

  2. esmi
    Forum Moderator
    Posted 5 years ago #

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

  3. mandawahoo
    Member
    Posted 5 years ago #

    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;">

  4. alchymyth
    The Sweeper & Moderator
    Posted 5 years ago #

    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?

  5. mandawahoo
    Member
    Posted 5 years ago #

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

  6. SpankMarvin
    Member
    Posted 5 years ago #

    Try replacing orderby with order?

  7. SpankMarvin
    Member
    Posted 5 years ago #

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

  8. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    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.

  9. mandawahoo
    Member
    Posted 5 years ago #

    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!

  10. mandawahoo
    Member
    Posted 5 years ago #

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

  11. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic