Past Events in Search Results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Past Events in Search Results

This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 1 year, 1 month ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #42309
    dstevens2322
    dstevens2322
    Participant

    I want to show only the future events in the search results. How can I make this possible?

    #42324
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Very likely! It strongly depends on how the events and the event data is stored. There is very likely a date field of some sort, where you can specify the event start and end dates?
    Usually creating a date filter (it does not have to be visible) to exclude the events ending before the current date is the trick. For that however we need to know what the field name is. Do you use any plugin by any chance to store the events, like Events Calendar or similar?

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #42335
    dstevens2322
    dstevens2322
    Participant

    Yes, I am using eventon. https://docs.myeventon.com/documentations/event-post-meta-variables/ . I was told before purchasing that this would be possible with eventon. But I am unsure of how to make it the current date continuously. I was able to see the filter section and how to hide it.

    #42336
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank you very much, that is actually very helpful.

    Based on their documentation, I believe using a small custom code snippet is the best option here:

    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'     => 'evcal_srow',
    		'value'   => time(),
    		'operator' => '>=',
    		'allow_missing' => false
    	);
    	return $args;
    }

    Try adding this code 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 need help, then let me know.

    If their documentation is correct, then this code should filter out every event which started before the current date, and olny show the ones that does not started yet.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #42342
    dstevens2322
    dstevens2322
    Participant

    Thank you so much. This worked perfectly.

    #42343
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.