WordPress.org

Ready to get started?Download WordPress

Forums

Sorting Posts By Date problem (5 posts)

  1. actionbasic
    Member
    Posted 3 years ago #

    Hi all,

    Terrible title, I know. Wasn't sure how to explain this one quickly. Here is my site: majesticdetroit.com

    I am using this code to sort my events in my sidebar by a custom date field:

    <?php $recent = new WP_Query('cat=45&showposts=15&orderby=meta_value&meta_key=Date&order=ASC'); while($recent->have_posts()) : $recent->the_post();?>

    Basically, what is happening is that events with a date of 03/10/11, or anything in 2011 are being sorted and showing at the top of my events list. I need to know how to get around this. Is this a WordPress issue? Or is it my code?

    Any help would be great!

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Use a yyyy/mm/dd format for your custom meta.

  3. actionbasic
    Member
    Posted 3 years ago #

    If I do that, is there still a way to output it as 03/10/11 ?

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    Yes. You should be able to grab the dat meta value, use explode() to break it down into it's components and then re-assemble it in any form that you want.

  5. actionbasic
    Member
    Posted 3 years ago #

    Hmmm. Time for some research. No idea how to do that. :)

Topic Closed

This topic has been closed to new replies.

About this Topic