Support » Plugin: Post Expirator » Query by date

  • Hello ! its posible create custom queries for display expiration post by date ?

    Today, this week, this month…

    Example :

    switch ($date) {
            case 'today':
                return array(
                    'key'       => '_expiration-date',
                    'value'     => date('Y-m-d',strtotime("today")),
                    'compare'   => '=',
                    'type'      => 'DATE'
                );
                break;
            
            case 'this-week':
                return array(
                    'key'       => '_expiration-date',
                    'value'     => array(date('YYYY-MM-DD',strtotime("Monday this week"), date('YYYY-MM-DD',strtotime("Sunday this week")))),
                    'compare'   => 'BETWEEN',
                    'type'      => 'DATE'
                );
                break;
             case 'this-month':
                return array(
                    'key'       => '_expiration-date',
                    'value'     => array(date('YYYY-MM-DD',strtotime("Monday this week"), date('YYYY-MM-DD',strtotime("Sunday this week")))),
                    'compare'   => 'BETWEEN',
                    'type'      => 'DATE'
                );
                break;
        }
    • This topic was modified 1 year, 4 months ago by  cuviline.
    • This topic was modified 1 year, 4 months ago by  cuviline.
Viewing 1 replies (of 1 total)
  • Plugin Author Aaron Axelsen

    (@axelseaa)

    The value is stored as a GMT/UTC timestamp value in the post meta data. Keep the timezone in mind when setting up your query. So if you craft your query correctly, I don’t know why it wouldn’t work.

    Good Luck!

Viewing 1 replies (of 1 total)
  • The topic ‘Query by date’ is closed to new replies.