Support » Fixing WordPress » Sort by date, then alpha

  • This may be a little unusual, but I am trying to sort my posts by date, but then alphabetically within that date.

    It seems that no matter what I have tried, it sorts either alphabetically, or by date and time.

    Any ideas?



Viewing 4 replies - 1 through 4 (of 4 total)
  • As in per day? per month?

    Either way, the problem is that the date/time of a post is all in one column (which is almost always how it is), but that makes it difficult (unless I’m missing something) to do what you’re asking.

    Currently, the only way I can think to do this is to make a query for each day. Although I just though of another way to do it. I’ll get back to you.

    By day. For example, what if you wanted to make a list of people’s birthdays. The date is important, but not the specific time, and it would be easier to go through a list alphabetically.

    I started with the alphabatizing posts script and modified that to look like this:
    // we add this, to show all posts in our
    // Glossary sorted alphabetically
    if (is_category(‘Glossary’))
    $posts = query_posts($query_string .
    // here comes The Loop!
    if (have_posts()) : while (have_posts()) : the_post(); ?>


    This just ends up alphabatizing it. If I comment out the &orderby=title then it sorts by date and accepts the ascending command.

    I also tried &orderby=year&orderby=month&orderby=day, but I’m not even sure if those are recognized terms. It didn’t give me an error though.



    That won’t work as if you order by date, that’s ordering by date AND time.

    As I discovered … although the MySQL reference says the date function extracts only the date and not the time.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sort by date, then alpha’ is closed to new replies.