• Resolved stevebeavis

    (@stevebeavis)


    Thanks for the plugin which is very useful. I have successfully created a sorted list of a particular category from a directory created with Web 2.0 directory plugin using the shortcode:

    [display-posts post_type=”w2dc_listing” taxonomy=”w2dc-category” tax_term=”events” meta_key=”_content_field_12_date_start” orderby=”meta_value_num” order=”DESC”]

    I am trying to get a filter working to show only future dated events and not past dated events by adapting one of the filters you have provided on your site:

    ———-
    function be_dps_future_events( $args, $atts ) {

    // Only run on directory queries
    if( ‘w2dc_listing’ != $args[‘post_type’] )
    return $args;

    $args[‘order’] = ‘ASC’;
    $args[‘orderby’] = ‘meta_value_num’;
    $args[‘meta_key’] = ‘_content_field_12_date_start’;
    $args[‘meta_type’] = ‘datetime’;

    $args[‘meta_query’] = array(
    array(
    ‘key’ => ‘_content_field_12_date_start’,
    ‘value’ => date( ‘dd-mm-yyyy H:i:s’, current_time( ‘timestamp’ ) ),
    ‘compare’ => ‘>’
    ) );

    return $args;
    }
    add_filter( ‘display_posts_shortcode_args’, ‘be_dps_future_events’, 10, 2 );
    —————————-

    But my list which can be seen below the calendar on this page:

    http://eflowriders.concisedigital.net/calendar-test/

    Is still showing all the events in the category including those with a past start date.

    Any idea why my future events filter is not working?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Filter for current and future dated posts’ is closed to new replies.