Forum Replies Created
-
AuthorPosts
-
December 5, 2022 at 11:47 pm in reply to: Specific custom post type not showing up in search results #40419
thebizpixie
ParticipantBrilliant! That fixed it perfectly.
Thank you so much.
thebizpixie
ParticipantI think I’m going to leave this one for now. It’s not a critical feature to have at this point in the project, so I’m going to leave the URL as the default, and return to it at a later date if need be.
Thanks for all of your help with this. We made great progress, and created a solid foundation for tackling this in the future.
thebizpixie
ParticipantOK, so I’ve tested the var_dump and there is a difference.
Without redirect
URL is /?s=frog&asp_active=1&p_asid=1&p_asp_data=1&filters_initial=1&filters_changed=0&qtranslate_lang=0¤t_page_id=36192array(8) { ["s"]=> string(6) "frog" ["asp_active"]=> string(1) "1" ["p_asid"]=> string(1) "1" ["p_asp_data"]=> string(1) "1" ["filters_initial"]=> string(1) "1" ["filters_changed"]=> string(1) "0" ["qtranslate_lang"]=> string(1) "0" ["current_page_id"]=> string(5) "36192" } NULLWith redirect
URL is /search/frog/?asp_active=1&p_asid=1&p_asp_data=1&filters_initial=1&filters_changed=0&qtranslate_lang=0¤t_page_id=36192array(7) { ["asp_active"]=> string(1) "1" ["p_asid"]=> string(1) "1" ["p_asp_data"]=> string(1) "1" ["filters_initial"]=> string(1) "1" ["filters_changed"]=> string(1) "0" ["qtranslate_lang"]=> string(1) "0" ["current_page_id"]=> string(5) "36192" } NULLSo there only difference is that the “s” parameter is missing from the _GET array with the redirect, but then that makes sense because we’re redirecting the URL.
As a test, I added the ‘s parameter back to my URL, so now the redirection rule reads:
RewriteCond %{QUERY_STRING} \\?s=([^&]+)\&(.*) [NC] RewriteRule ^$ /search/%1/?s=%1&%2 [NC,L,R]and the URL now contains the search term twice:
/search/frog/?s=frog&asp_active=1&p_asid=1&p_asp_data=1&filters_initial=1&filters_changed=0&qtranslate_lang=0¤t_page_id=36192
and voila, it now overrides the results correctly, so that part of the problem is now resolved.
Unfortunately, if I filter down my results using the settings, the URL still reverts to the original URL ie. /?s=frog and loses the redirected version of the URL.
Note: Setting the Custom redirect URL to “/search/{phrase}/” does not seem to have any effect.
Any ideas why this is happening and what I can do about it?
Thanks for your patience and persistence with this.
thebizpixie
ParticipantYou’re absolutely right that the redirect rule was not correct, and I should have checked it more closely. I also forgot that GET was required to make this all work as desired.
I have rewritten the rewrite rule to behave correctly, I believe:
RewriteCond %{QUERY_STRING} \\?s=([^&]+)\&(.*) [NC]
RewriteRule ^$ /search/%1/?%2 [NC,L,R]such that the original search URL:
now redirects to the desired URL with the parameters attached:
but unfortunately the results on the redirected page are still not coming from Ajax Search Pro, but are instead the default WordPress results.
Another piece of the puzzle is that when I filter down my results on the redirected page using the settings box (and my custom field “content type”), the URL reverts to the default WordPress URL, but still does not override the results.
i.e. The URL changes to:
https://mydomain.com/?s=frog&asp_active=1&p_asid=1&p_asp_data=1&aspf%5Bcontent_type__1%5D%5B3%5D=Video&filters_initial=0&filters_changed=1&qtranslate_lang=0¤t_page_id=36861I don’t fully understand why this happens, but it might be a clue to part of what is going on.
Can you see any issues with this, or think of anything else that I could explore here?
Thanks for your input.
thebizpixie
ParticipantYeah, I tried that already, so all of this testing has been with the soft check feature on, and still the override doesn’t work on the modified URL.
If there’s nothing else I can try, I think I may have to accept that I can’t modify the default search results page URL and still have Ajax Search Pro work correctly.
If I have to choose between modifying the URL and using Ajax Search Pro, then I choose Ajax Search Pro, but if you do find a solution at any point, I’d love to know about it.
thebizpixie
ParticipantOK, well at least I know that’s the limits I’m working within. Thanks for confirming.
thebizpixie
ParticipantOK, I believe I have made some progress with this, using the div that includes only the results list and not the search input or the filter block.
It seems that the live loading only works via GET and not POST. Is this the expected behaviour?
I would prefer not to have the parameters in the URL, but please let me know if this is indeed expected behaviour and the only way to get live loading working.
Thanks.
thebizpixie
ParticipantTo clarify, I DO want the search bar on the results page, but I DON’T want the hover to show when I select filter settings. I only want the hover to display when someone types directly into the search input box.
I do want the results list to update as someone modifies the filters via the settings. (see above screenshots)
I have activated the live search feature, and played with a number of different DIV ID’s to get the page to update, but none are behaving as expected.
If I choose any div (by ID) that includes the top search input form e.g. #page-container or #main-content (I’m using Divi)
>> reloads page, search results don’t change, resets filters back to their initial values
and if choose a div that contains the results list, but not the search input box, but includes the search filters block
>> reloads section, search results don’t change, filter settings disappear
and if choose a div that contains the results list, but not the search input box or the search filters block
>> reloads section, search results don’t change, filter settings remain intact (this one seems to work the closest to what I want, except for the whole “search results not updating” part)In all cases, the search results don’t change and filters don’t appear to apply.
On my main search page I have inserted:
[wpdreams_ajaxsearchpro id=1]
and hidden the filter settings block with CSS.On my search results page I have used both:
[wpdreams_ajaxsearchpro id=1]
AND
[wpdreams_asp_settings id=1]
in two separate locations, so the filters associated with the search input are hidden, and the filters display separately, just above my results list.Is there a way to achieve the desired behavior using one search form? I’m happy to record a screencast if the behaviour I’m trying to achieve is still not 100% clear.
thebizpixie
ParticipantI’m comfortable with .htacess rules, and the redirection rule worked perfectly using htaccess instead of the function.
But the results on the search page still revert to the default WordPress results, and not the Ajax Search Pro query.
Any other suggestions as to how I can get the Ajax Search Pro query passing through to the redirected page and overriding the WordPress results?
thebizpixie
ParticipantI think the solution might look something like this, but I’m just not sure on the right way to approach it:
https://wp-dreams.com/forums/topic/custom-results-page-with-elementor/thebizpixie
ParticipantThank you.
thebizpixie
ParticipantYes, I have tested this on another similar page, and I was bale to to save my changes and view the modified page that included the search box, and no additional windows were opened during that process.
So it looks like the issue has been fixed.
I look forward to the official release so I can test it on my main dev site as well.
Thanks for your help with this.
thebizpixie
ParticipantYou cannot access this content.
-
AuthorPosts