Support

Account

Home Forums General Issues Display post in date field select

Helping

Display post in date field select

  • Hello i’ve create a date field and need to setting this to display the post on day select.

    So if select 12-12-2016 to 01-15-2017 my post must be display only in this date. Is possibile.

  • Hi @serviceweb

    Yes, you can do it. First, you need to get the current day by using the date() function. After that, you need to query the posts based on the current day. It should be something like this:

    $today = date('Ymd');
    
    $the_posts = get_posts(array(
        'numberposts'    => -1,
        'post_type'      => 'post',
        'meta_query'     => array(
            array(
                'key'         => 'date_picker_field_name',
                'value'          => $today,
            ),
        ),
    ));
    print_r($the_posts);

    Don’t forget to change the “date_picker_field_name” text with your date picker field name. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/query-posts-custom-fields/.

    Also, please keep in mind that there are differences between date picker field in PRO and free version. To learn more about it, kindly check this page: https://www.advancedcustomfields.com/resources/date-picker/.

    I hope this helps 🙂

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Display post in date field select’ is closed to new replies.