Support

Account

Home Forums General Issues Comparing post_date and start_date meta field

Unread

Comparing post_date and start_date meta field

  • Hello,

    I have a custom page template that needs to display posts created after a certain date. The start_date custom field value is set using the Date Picker. Various pages will have different start dates that will need to be compared against the post dates. Is there a way to compare a post’s date to the page’s start date? I have included my current code below, but it does not work.

    $args = array(
        'post_type' => 'sendouts',
        'cat' => '101',
        'post_per_page' => '-1',
        'order' => 'DESC',
        'orderby' => 'post_date',
        'meta_key' => 'start_date',
        'meta_query' => array(
            array(
                'key'=> 'post_date',
                'compare' => '<=',
                'value' => 'start_date',
                'type'=> 'DATETIME'
            )
         ),
    );
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.