This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

can I exclude past events?

Home Forums Product Support Forums Ajax Search Pro for WordPress Support can I exclude past events?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #53192
    HDenkmireHDenkmire
    Participant

    My problem is that I am self-taught, and not someone who codes. I figure things out as I go. I can’t figure out how to tell the Ajax Search plugin to not look at events that have already passed by. I have it searching events, because I want upcoming events to show up, but I would like to tell the plugin not to pull events that are older than today. Is this possible.

    #53195
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    Yes! It is possible via a custom code snippet:

    add_filter("asp_query_args", "asp_query_args_apply_date", 10, 2);
    function asp_query_args_apply_date($args, $search_id) {
    	$args['post_meta_filter'][] = array(
    		'key'     => '_EventStartDate',
    		'value'   => date('Y-m-d'),
    		'operator' => '>=',
    		'allow_missing' => false
    	);
    	return $args;
    }

    Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    If you are using the snippets plugin, make sure the code can run everywhere.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.