1

i want to custome post by ASC. i have some add some post in bachend one of the field date picker. i want to post by date which i set in date picker field

<?php
        $args = array(
             'post_type'=>'upcoming_events',
             'order' => 'ASC',

       );
        global $more; 
        query_posts( $args ); 
        while (have_posts()) : the_post(); 
        ?>

Ex. some post which i set date(datepicker cusomefiled) and title output is below DATE(datepicker) title

19-12-2013 London 29-12-2013 Spain 15-01-2014 Paris

i want to

DATE(datepicker) title

15-01-2014 Paris 19-12-2013 London 29-12-2013 Spain

  • Please look to the side under "Related" for the "date picker" and "order by custom field" questions. – s_ha_dum Dec 18 '13 at 15:28
1

So what you need to do is order it by the custom value of the meta_key date value.

Something like this (untested):

$wp_query = new WP_Query( array(
    'post_type' => 'upcoming_events',
    'order' => 'ASC',
    'meta_query' => array (
        array (
            'key' => 'your_custom_date_key',
            'value' => date('Y-m-d')
            )
        ),
    'orderby' => 'meta_value'
    )
    );

Hope that helps.

| improve this answer | |
1
$args = array(
                        'post_type' => 'upcoming_events',
        'posts_per_page' => 30,
        'meta_key' => 'date',
        'orderby' => 'meta_value',
        'order' => 'ASC',
            'meta_query' => array(
                array(
                   'key' => 'date',

               )

        ));
| improve this answer | |
  • Please add an explanation how and why this solves the problem. – Nicolai Dec 19 '13 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.