Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author metaphorcreations

    (@metaphorcreations)

    Thanks for the suggestion. That may be something I can implement in the future.

    This is an important implementation even for me. There may be news soon?
    Thanks, Carlo

    Plugin Author metaphorcreations

    (@metaphorcreations)

    I still have it on my list of potential updates, but I don’t have any idea of when or if I will be implementing it.

    Since I just needed to do this on a site I figured I’d post a quick solution. I used Advanced Custom Fields to add a meta field to the ditty_news_ticker post type. You can use whatever post_meta plugin you prefer.

    In my case the date is stored in Ymd format, ex: 20160629

    I wanted to display the latest non-expired ticker (if there is one) in the header of the site so I just used the following get_posts() query — note that the meta_key for my custom field is expiration_date:

    //- get most recent news ticker
            $args = array(
                'post_type' => 'ditty_news_ticker',
                'posts_per_page' => 1,
                'meta_query' => array(
                    'relation' => 'OR',
                    array(
                        'key' => 'expiration_date',
                        'compare' => 'NOT EXISTS'
                        ),
                    array(
                        'key' => 'expiration_date',
                        'value' => date( 'Ymd' ),
                        'meta_compare' => '<='
                    )
                )
            );
    
        if( $ticker = reset( get_posts( $args ) ) ){
                if( function_exists( 'ditty_news_ticker' )){
                    ditty_news_ticker( $ticker->ID ); }
        }
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Would be nice to have expiration date/time option’ is closed to new replies.