How can I sort (orderby) my post by custom field value (3 posts)

  1. dinesh786
    Posted 3 years ago #

    Hello friends,

    I have a custom post type "News"
    and with news I added a custom field "choose_date" (we want to give our own date instead of wp date )

    now I want to show post order by "choose_date" field
    than what should i do? any method or idea to do this?

    My current query arguments are
    $args = array(
    'post_type'=> 'news',
    'order' => 'DESC',

    what should I add in this?
    Please help me

    I used 'orderby' => 'meta_value', 'meta_key' => 'choose_date'

    But its not giving in proper order

  2. dinesh786
    Posted 3 years ago #

    Ok, Its working fine,
    But the DB stored values in "Sep 27, 2012" format

    I used Custom field plugin and used Date Picker field type for choose_date field

    any solution to store date value in integer format?

  3. dinesh786
    Posted 3 years ago #

    Can I do filter values by query like:

    'meta_query' => array(
    'key' => 'choose_date',
    'value' => date("M d, Y"),

    value stored in db in string date format, and i want to fetch order by date

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.