Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Issue with result group by meta key
- This topic has 55 replies, 2 voices, and was last updated 7 years ago by
Ernest Marcinko.
-
AuthorPosts
-
April 5, 2019 at 5:18 am #22027
davidalexander
ParticipantPerfect. It’s working fine. Only one thing, if we select a date like 10/05/1019 in the search settings option, we will get only the events which event start date equal to the date. But we need to show the events, which starts on 05/05/2019 and ends in 12/10/2019. Because the event is in between 05/05/2019 and 12/10/2019.
April 5, 2019 at 7:39 am #22032Ernest Marcinko
KeymasterHi,
Make sure, that the filter is set to the correct criteria (after the date): https://i.imgur.com/dAuBCMq.png
April 5, 2019 at 7:50 am #22033davidalexander
ParticipantHi,
But it’s not working as we needed. If we set this as after date, suppose the user searched for events after 10/05/1019, they will not find the vent start in 05/05/2019 and ends in 12/10/2019.April 5, 2019 at 7:59 am #22034Ernest Marcinko
KeymasterHi,
Of course not, because events starting after 10/05/1019 does not include events starting at 05/05/1019, because that starts before that date, and not after. The matching date does not compare between two dates, it matches the selected custom field for that date.
Maybe a filter on event ending date would be better for you – events ending before the selected date, that includes the currently running events, as well as events that start later, but end before the selected date.April 5, 2019 at 10:34 am #22039davidalexander
ParticipantCan you customise the code to get the events in the searching date if the date is in between the start and ed date of events. Can you change the date search query in plugin’s file
April 5, 2019 at 2:00 pm #22044Ernest Marcinko
KeymasterHi,
Sure, it was possible with minor changes. I have changed one of the functions within the child theme directory, plase keep it there:
add_filter('asp_query_args', 'asp_reset_date_filter'); function asp_reset_date_filter($args) { if ( isset($_POST['autop']) ) { foreach ( $args['post_meta_filter'] as $k => $v ) { if ( $v['key'] == '_event_start' ) { unset($args['post_meta_filter'][$k]); } } } else { $val = ''; foreach ( $args['post_meta_filter'] as $k => $v ) { if ( $v['key'] == '_event_start' ) { $val = $args['post_meta_filter'][$k]['value']; } } $val1 = date('Y-m-d', strtotime($val) - 24 * 60 * 60); $val2 = date('Y-m-d', strtotime($val) + 24 * 60 * 60); $args['post_meta_filter'] = array( array( 'key' => '_event_start', 'value' => $val2, 'operator' => 'datetime <' ), array( 'key' => '_event_end', 'value' => $val1, 'operator' => 'datetime >' ) ); } return $args; }April 6, 2019 at 6:25 am #22055davidalexander
ParticipantGreat thanks Ernest. It’s working perfect.
April 18, 2019 at 12:22 pm #22241davidalexander
ParticipantHi,
I have added load more results option in ajax result. And set up the limit as 6. But, by default when the page loads it shows only one event, and when we click on the load more option it will show next 6 events etc. I need to show first 6 events by default.April 18, 2019 at 1:12 pm #22242Ernest Marcinko
KeymasterHi,
It is because of the removed duplicates. The only possible solution here is to increase the limit, and hope that less duplicates remain. Because the duplicates must be removed after the search process, the results number can be different from the limit set.
April 18, 2019 at 1:37 pm #22245davidalexander
ParticipantPerfect. Thanks.
One more question, I have added a meta field event type for all events. And I have added this meta value for filtering.
When it first loads it loads events for the particular category (another meta field) you are on. If you then do a search or filter (even by event or exhibitions ( event type)) the results are from all categories. Could you take a look pls. Thanks
https://lmg.alexandermarketing.co.uk/lotherton/whats-on/April 18, 2019 at 2:05 pm #22247Ernest Marcinko
KeymasterHi,
Maybe those are items that does not have categories assigned. Try turning off this option: https://i.imgur.com/Q5X3WGv.png
April 22, 2019 at 5:56 am #22260davidalexander
ParticipantHi,
It’s not working yet. I have checked with the way you mentioned.
https://lmg.alexandermarketing.co.uk/lotherton/whats-on/All the events have event category and event type. I need to sort out events under a category with the type( event or exhibition). Can you please check once again.
Could you please customise the plugin code for me.
-
This reply was modified 7 years, 1 month ago by
davidalexander.
April 23, 2019 at 9:48 am #22267Ernest Marcinko
KeymasterHi,
Maybe I am missunderstanding the problem, I have tried a few tests, but I am getting the correct results I think. Selecting the ‘Exhibitions’ gives me only 10 results, which seems to be correct, as on the back-end there are 10 events associated with the category ‘Exhibitions’. I am not seeing those results when selecting ‘Events’, so it seems to be okay. (?)
April 23, 2019 at 10:00 am #22268davidalexander
ParticipantHi,
If we look at https://lmg.alexandermarketing.co.uk/lotherton/whats-on/ as the example.
When the page first loads it loads only Events and Exhibitions relating to the Venue ‘Lotherton’
However, when you then select either the Events or the Exhibitions link it pulls back results for all other venues and not just those for Lotherton.So when I click Events from this page I should only see ‘Lotherton’ events. Same for ‘Exhibitions.
Thanks
April 23, 2019 at 10:17 am #22269Ernest Marcinko
KeymasterHi,
Okay, I see the issue now. I think the problem is caused by using the filter (checkbox) that is invisible, instead of an inclusion option. Instead of the current configuration, try something like this:
– Turn off the checkbox, as it is not needed: https://i.imgur.com/pfNZkaI.png
– Use the category inclusion option: https://i.imgur.com/EI7WLa7.png
That should restrict them correctly. -
This reply was modified 7 years, 1 month ago by
-
AuthorPosts
- You must be logged in to reply to this topic.