WordPress.org

Ready to get started?Download WordPress

Forums

sort order problems WP2.0.2 (2 posts)

  1. syncbox
    Member
    Posted 8 years ago #

    This is odd. I have a query set up like this:


    <?php
    if (is_category()) { query_posts('cat=50&numberposts=10&order=ASC&orderby=post_title');
    }
    ?>

    and it works... it sorts the posts by the post title, alphabetically from a->z. This is on child of a category (so the categories are crew/current-crew)

    but I put the SAME query on another child category, and the sort is just the opposite! So, using:


    <?php
    if (is_category()) { query_posts('cat=51&numberposts=10&order=ASC&orderby=post_title');
    }
    ?>

    for crew/former-crew, I get titles sorted z->a.

    WTF? Why? And in testing, I just went ahead and changed the ASC to DESC and lo! sorts from a->z

    So I guess I have a solution, but why? I was noticing the same problem with the custom query plugin (which is supposed to allow you to select the number of posts and sort them, but suffered the same issue with sometimes working and sometimes not). That's why I decided to figure out how to write my own query for it.

    Can someone please explain this behavior or is this just a bug?

  2. syncbox
    Member
    Posted 8 years ago #

    I still don't know why this was behaving this way, but I managed to find a plugin whose code I could use to get alphabetical asc sorting and ordering...

    http://www.mikesmullin.com/2006/05/23/wordpress-plugin-sort-category-posts-by-title/

    using the code in the actual category template before the query rather than as a plugin affecting all category posts.

Topic Closed

This topic has been closed to new replies.

About this Topic