Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Compatibility with Divi Filter Grid
- This topic has 15 replies, 2 voices, and was last updated 1 year, 8 months ago by
Ernest Marcinko.
-
AuthorPosts
-
September 23, 2024 at 6:03 pm #50189
FreshySites
ParticipantHi there!
I’m having a hard time getting the plugin Divi Filter Grid to display the same results as the Ajax Search Pro search field is showing (the ajax dropdown that loads posts). But for some reason, it shows the correct results for the default Divi Blog Module after you hit “Return/Enter” on the Search Results page. Even when the Query Type is set to “Archive Page (category, search, etc) it doesn’t show the same results. In fact none of the Query Types show the correct results even though the default Blog Module does. I’ve also tried switching these two: http://freshy.cc/5c2sM9yc I also tried changing the “Order By” to “Search Relevance”.
I reached out to the Divi Filter Grid devs about this and they mentioned my best option would be to go through the support of Ajax Search Pro and ask how we can integrate your plugin into their plugin which uses a new instance of wp_query(). Most plugins like this allow you to add a query parameter to the wp_query class to achieve this. We just need to find out from the developers what the parameter or method is for Ajax Search Pro. The default blog module has a much more simple query than Divi Filter Grid and in most cases does not use the wp_query class which is probably why it’s working on that module.
Thanks!
September 24, 2024 at 8:40 am #50197Ernest Marcinko
KeymasterHi!
The new instance of the $wp_query explains the issue, as it’s not longer the main query, and the override method does not trigger.
Before jumping into coding, you should try this option first. This will bypass some query checks and more likely triggers the override, often time this is all it takes.
As for the integration, there an attribute to set on the $wp_query object – but it happens to have a bug with the current release (what a coincidence), still it’s possible to make it work.
Integration for plugin devs to trigger the override
Normally, if the following query variable is set, the plugin will trigger an override, this is all they need to set in the filter grid plugin in $wp_query to integrate:
$wp_query->set( 'asp_override', true );
When this query variable is set, the plugin will trigger the override. Please let them know 🙂I’m also attaching a patched beta release to this reply, that has the query variable fix included.
September 26, 2024 at 4:51 pm #50369FreshySites
ParticipantHi Ernest!
Apologies for the late response! With your patch and a custom query with DFG, looks like they both work together now!
Thanks so much!!
September 27, 2024 at 8:37 am #50407Ernest Marcinko
KeymasterThank you very much!
Do you mind if I ask if this the folks had to change something in the divi grid, or you only had to add an option somewhere? I’m curious as then I can add a demo to the website with the Divi filter grid too 🙂
September 30, 2024 at 5:26 pm #50966FreshySites
ParticipantYou cannot access this content.
October 1, 2024 at 7:02 am #51040Ernest Marcinko
KeymasterIt is because of the var_dump, because it pollutes the json response, that the divi filter grid tries to parse – that of course will break, that’s expected when you change the output, but it’s not related to the search.
I’m afraid there it’t not yet documented, but it’s a simple boolean value of true or false. When true, it will signal Ajax Search Pro to capture and cancel the current query and replace the results from it’s own query results. That’s all it does 🙂
/** * When true, Ajax Search Pro will capture the $wp_query (WP_Query) in the following way: * -> on "posts_request" hook it checks if $wp_query->query_args['asp_override'] === true * -> if true, cancels the current query by setting the request $request = '' * -> on "posts_results" hook checks again, and overrides the posts returned with the results from it's own query * This means that the original query is cancelled, then the results are swapped. **/ $query_args['asp_override'] = true;October 1, 2024 at 2:07 pm #51085FreshySites
ParticipantHi Ernest!
After showing your response to the Divi Filter Grid devs they believe since the asp_override argument is cancelling the Divi Filter Grid query completely, that means it’s going to cancel the sort order since that is also included in the query. Unfortunately it seems like the two plugins are incompatible.
October 1, 2024 at 2:19 pm #51091Ernest Marcinko
KeymasterThat could be very likely resolved from our side.
Can you ask if they use any special ordering arguments or are they setting it in the query args like in WP_Query? If so, can they let me know which ones exactly?
Also, is there a query argument similar to the “asp_override” or anything special that their plugin sets, so I can reliably detect if the query is related to the filter grid?With that I can very likely add a minor modification to the plugin code to explicitly set the same ordering arguments.
October 1, 2024 at 4:56 pm #51149FreshySites
ParticipantHere is the developer’s response to your questions:
We are setting the order in WP_Query and performing an AJAX query to update the results with the new order.
We have several query arguments they can check to detect if the query is related to the filter grid. Here is an example:
isset( $query->query[‘dfg_context’] )
dfg_context can have multiple values. If the argument exists at all, it is coming from Divi FilterGrid.
October 2, 2024 at 10:07 am #51233Ernest Marcinko
KeymasterGreat!
I’m attaching a modified version, which checks this variable and changes the ordering accoding to the query ordering. I was not able to test it ufnortunately, so I’m only guessing. If you see no change, then can you please add temporary back-end and FTP access? I will try to directly debug through the code, this should be solvable in my opinion.
October 2, 2024 at 12:46 pm #51235FreshySites
ParticipantYou cannot access this content.
October 2, 2024 at 1:54 pm #51236Ernest Marcinko
KeymasterThank you!
I may have found a possible solution. Please note that the search filters can’t be used, as those are not sent along with the ajax request when the sorting is triggered within the filter grid. (that is actually how it should be, so it’s perfectly fine)
Can you please disable all front-end filters, especially the generic filters on the search bar. With the filters the parser would assume that the checkboxes were unchecked and those fields would be disabled. There is unfortuantely no way to technically send that filter data along, as you can have multiple search bars and it would be super hard to tell which data is relevant – overall it would be a mess.
Either way, after disabling the filters it should apply to the filter grid as well, and give you very close results as if the actual live search was used.
October 2, 2024 at 3:39 pm #51237FreshySites
ParticipantHi Ernest! It sorta worked, but when I sort the results by date or author it only shows one post and the others disappear.
We also need the front-end filters with the ASP search bar to stay because that’s what our client really wanted.
Do you think replacing Divi Filter Grid with the ASP Result shortcodes or Divi Blog Module would be a better option? Maybe with the Live Trigger results? I’m having trouble getting that to work with the Divi Blog Module. That way we could just use the filters and ajax capabilities built into ASP.
October 2, 2024 at 3:48 pm #51239Ernest Marcinko
KeymasterHi Ernest! It sorta worked, but when I sort the results by date or author it only shows one post and the others disappear.
That is because of the filters as I mentioned previously.It’s going to be either or, no way to combine them both – if you turn off the sorting and all other filters on the divi filter grid and use the filters from ajax search pro, that should still work in combination with the Results Page live loader feature. In you case use the
#fs-searchquery selector: https://i.imgur.com/4xxO8IT.pngThat will reload the results page in the background with the new parameters that will apply on the filter grid. Anything that is loaded via ajax within the filter grid should be also turned off – especially pagination. If there is only an ajax “live” pagination possible, then it might be a good idea to show more results and turn off the pagination.
With that however you could probably use a different module. Divi probably has like an archive page module specifically for search results, those should work right off the box as those are designed for archive pages (including the search results).
October 2, 2024 at 5:43 pm #51243FreshySites
ParticipantOh nice, yeah it looks like just using ASP’s filters with the default blog module and triggering the live search is the best option instead of trying to use DFG’s sorting and filters.
Thanks for your help looking into this for me! Hopefully our client will be ok with this solution instead of trying to use the DFG filters and stuff.
-
AuthorPosts
- You must be logged in to reply to this topic.