Forum Replies Created
-
AuthorPosts
-
Ernest Marcinko
KeymasterSure Samuele! I would also prefer a custom code snippet if I were you, good choice 🙂
This is what you are looking for:
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' => 'start-date', 'value' => strtotime("today", time()), '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.
Ernest Marcinko
KeymasterYou cannot access this content.
Ernest Marcinko
KeymasterMake sure to change the layout to a block here. That will display the results correctly below the search bar.
Ernest Marcinko
KeymasterHi Samuele,
Yes – it is possible two ways – one is a bit of custom code snippet, or if you are not using the search filters, then that is also an option. Search filters are effective even if they are invisible.
Therefore you can create a date filter on that field like so: https://i.imgur.com/rGCSVpw.png
This will filter out results where the “start-date” is before today.Ernest Marcinko
KeymasterErnest Marcinko
KeymasterHi,
I recommend checking this tutorial for that. It describes how to set up this search bar, which is probably very close to what you are looking for 🙂
Ernest Marcinko
KeymasterHi,
Thank you very much for the details, it helps a lot!
I have found the issue. The problem is, that on the search sources, there are a few more post types selected as in the filter itself. For example the Campaigns is selected as the source, but it’s not in the filter options. This results in Campaings being always included in the results – regardless of the filter state.
Select the same post types in the filter as in the Search Sources will resolve the issue.
Ernest Marcinko
KeymasterHi,
This might be related to a container ID issue, which was reported earlier with the latest Elementor version. I’m attaching a beta version to this reply, please install it, clear all layers of cache, and the issue should be resolved.
Ernest Marcinko
KeymasterYou cannot access this content.
Ernest Marcinko
KeymasterYou cannot access this content.
Ernest Marcinko
KeymasterYou cannot access this content.
Ernest Marcinko
KeymasterYou cannot access this content.
Ernest Marcinko
KeymasterYou cannot access this content.
Ernest Marcinko
KeymasterYou cannot access this content.
Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts