Forum Replies Created
-
AuthorPosts
-
November 18, 2016 at 12:33 am in reply to: How to modify isoptic load more pagination behaviour #10940
luyendao
ParticipantHi Ernest, sorry yes you’re right – the Load More reloads and paginates to the next page.
The modification i’m hoping to make is imagine there was no traditional pagination, the initial load had 10 results for example. Clicking Load More would load the next 10 below the initial set of 10 and so forth. So the user would keep scrolling down as they loaded more, this is common in blogs and such and wondering how I’d go about doing this here.
Thanks for any tips!
luyendao
ParticipantHi Ernest, thanks for your time – no worries about late responses I’m sure you get a lot of tickets and mine are probably the most annoying 🙂
I have another question for you – the solution above of running an additional query is the ideal way to do it. As a temporary solution what i’ve been doing is for a CPT such as Appleton (a city post type), I added a custom text field to that post type which contains the names of cities within a 50k radius. So if someone searches for Neenah for example, it will show Appleton – a kind of pseudo proximity search.
Of course this isn’t the right way to do it – I was just curious if the search engine can also search within an array, or serialized data? So let’s say instead of storing just a text string, i could store Neenah as a meta key, and a distance integer as a Meta Value.
Then when someone searches for Neenah – i can order the results by distance.
I’ve tried an ACF repeater but that didn’t work, apologies but i haven’t tried just regular custom fields out of the box, I will try that.
I know it’s not the best way to do things – but just wondering what is indexable. Thanks, promise not to bug you after this 🙂
-
This reply was modified 9 years, 8 months ago by
luyendao.
luyendao
ParticipantHi Ernest,
I feel bad asking for help all the time, but here goes:
I added this into my theme:
add_filter( ‘asp_only_non_keyword_results’, ‘asp_append_more_results’, 1, 2);function asp_append_more_results( $results, $id) {
switch ($id) {
case 11:$args = array(
‘s’ => ‘appleton’,
‘_ajax_search’ => true
);
$asp_q = new ASP_Query($args, $id);var_dump($asp_q);
return array_merge($asp_q->posts, $results);}
}11 – the search instance
s – “appleton” a string I know will return a resultIf I search for something gibberish like “jkaldkj129390123” that would be considered a non-result and trigger the above hook right?
I’ve tried variations of the search phrase such as an empty string, as well as keywords I know should match but it’s not showing up displaying “No Results” everytime. I cleared the search cache too, but not sure how to debug this.
My final objective is if I query a match or non-match, i can run another query that will find nearby cities, intersect and merge that array with what I have in my DB. Of course that part is outside of the scope of this plugin, but that’s there I need to get to to be able to run that query based on a match or non-match criteria.
I’m wondering if it’s better instead of using the ajax handler, I let the plugin override the wordpress ?s search functionality and run the logic in the search results “template”.
What do you think?
Thanks again for all your help – i bought another license for our production environment 🙂
luyendao
ParticipantHi Ernest,
Thanks that’s helpful to know how to modify the search phrase.
I’m not sure how to output the search phrase above the results in the first place – so it outputs “Your search for search_phrase” above the results. I was thinking if I can access the function that returns the $phrase, then output it into the hook ‘asp_add_header_data’ that should work?
When i added the code above on its own, i get nothing returned and the whole results array comes back empty.
I can pass a test string into asp_change_search_phrase() and get that back, but can’t seem to access $phrase itself.
I am running multiple search instances – any ideas?
Thanks again.
-
This reply was modified 9 years, 8 months ago by
luyendao.
luyendao
ParticipantHi earnest,
Thanks for your help – i can’t explain it. The hook when i tested it with the additional filter you provided returned empty, but for some reason on this one particular search instance it didn’t work. It would work on other instances I had – in the end i created a new instance and it worked fine, so I don’t know what the reason is but it’s OK.
luyendao
ParticipantHi Ernest,
I’m running into some issue, i tried the filter and initially that worked, i could see some additional text strings being appended to each result.
That was about 6 days ago when it worked, and today it stopped working. Of course my thought was did I do anything that could have changed it, i did make a bunch of settings changes to how things look but didn’t modify filter function you provided in the gist.
I double checked the $id matches, and modifying the copies of results templates in my themes folder still works as does everything else.
I have Query Monitor running, and don’t see anything being hooked in, can you recommend a way to debug this?
Thanks!
luyendao
ParticipantHi Ernest,
Thank for you taking the time to answer in such depth, i prefer using filters as well although in some cases templates ends up being easier (unfortunately).
Both of your researched examples are exactly what i need, once again thank you – your help and support are amazing.
I look forward to leaving a detailed testimonial for your product.
Luyen
-
This reply was modified 9 years, 8 months ago by
-
AuthorPosts