Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › How to have many Search Results Pages
This topic contains 9 replies, has 2 voices, and was last updated by Ernest Marcinko 3 years, 10 months ago.
- AuthorPosts
- February 5, 2020 at 4:10 am #25676
Hi,
on my website, I have two different search bars (both with Ajax Search Pro) and I would like them to point to two different Search Results Pages.
So I tried to implement two different templates for the Search Results Page, but I see WordPress just allows to apply one template to Search Results Page.So, I was wondering if the option ‘Redirect to: Custom URL‘ could be of any help when I click the Return button (or the Magnifier icon), in order to bring me to a ‘custom’ Search Results Page.
The thing is that, obviously, the custom URL (of the page that I created) is fixed and I don’t find a way to make it depend on the search so that the results shown would be the correct results of the search.Is this one the intent of that option? Can you suggest me how to implement a ‘custom’ Results Page?
Thanks in advance,
Daniele-
This topic was modified 3 years, 10 months ago by
danielecelsa07.
February 5, 2020 at 1:45 pm #25681Hi Daniele,
Unfortunately that won’t help. That option is only for cases where the results page is on a different permalink – but it still has to be the default wordpress results page.
Best,
WordPress will always handle the results page via the search.php template file in the theme directory. It might be possible to somehow custom code that template file for a conditional logic. The search IDs are sent via the$_GET['p_asid']
or$_POST['p_asid']
variables, that could be used to make separate loop layouts, in case you are planning to do that.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 5, 2020 at 3:28 pm #25683Hi Marcinko,
thanks for your answer.
What if I would create a search_2.php?
Would Ajax Search Pro work properly with a second Search Results Page? Would Ajax Search overwrite correctly the logic of results also on this second page?Thanks,
DanieleFebruary 5, 2020 at 3:30 pm #25684Hi Daniele,
No, that would not do anything there, as WordPress loads those files. You need to custom code a conditional logic within the search.php file (and maybe load a second file upon a condition), but I am not sure how that would work, as I have not seen anything like that before.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 8, 2020 at 4:34 am #25737Hi Ernest,
ok thanks, I will try to do this.
Meanwhile, I was thinking again to ‘Redirect to: Custom URL‘
I see that the special word {phrase} indicates what is typed in the search bar.
Is there maybe a special word also for Filter?
I would like to try to redirect to the page ‘mywebsite/filter_term/phrase‘ where ‘filter_term‘ is what is chosen in a filter applied to the search.Is this possible?
Thanks in advance,
DanieleFebruary 10, 2020 at 1:26 pm #25746Hi Daniele,
Actually, yes. It is not an officially supported or documented feature, but it should work with taxonomy and custom field drop-down (or radio button) filters.
Best,
You can use the same syntax, with the taxonomy or custom field name, like{taxonomy_name}
or{custom_field_name}
In case of categories/taxonomies it will replace it with the taxonomy term ID, in case of custom fields it will use the custom field value.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 10, 2020 at 2:26 pm #25748Hi Ernest,
thanks for your answer.
I see {taxonomy_name} redirect to the taxonomy term ID, is there a way to have the real value of the taxonomy term instead of the ID? This would solve my problem…
Is it weird that for categories/taxonomy it used the ID, while for custom_filed it is used the actual value. It would be useful to get the real value also for taxonomies..
Thanks,
Daniele-
This reply was modified 3 years, 10 months ago by
danielecelsa07.
February 10, 2020 at 6:08 pm #25751Hi Daniele,
That is the real value for taxonomy terms. Custom fields can have text values, while taxonomy terms are objects, which are identified by unique IDs. Using the taxonomy name there would be very problematic, doe to matching taxonomy names or slugs.
Best,
I’m afraid this is only possible by directly editing the plugin code.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
February 14, 2020 at 4:07 am #25813Hi Ernest,
thanks for your explanation!
I was trying to use a custom field filter, but I realized that I can use only custom field associated to CPTs.. How is it possible?
I added (through Advanced Custom Field plugin) custom fields to a Taxonomy.
So when I create a taxonomy term, I fill that custom field (text let’s say).In Ajax Search Pro I set the search bar to search for taxonomy (your plugin is wonderful also for this), I mean that I type taxonomy terms in the search bar and those are the results.
BUT I want to have a filter! I want to filter for Custom Field, the one associated to the taxonomy terms.
Why is this not possible? If it is possible to search for Taxonomy, there should be allowed also to filter them, I guess..In Index table setting, I don’t find at all the custom field created (I wanted to index it, if it was the problem), I can only index custom field related to CPT as far as I see.
Is this the correct behavior of the plugin, or am I missing something?
Anyway, can you suggest me a way to use a filter of custom fields related to Taxonomy terms?Thanks a lot as always!
DanieleFebruary 14, 2020 at 1:05 pm #25816Hi,
It is the correct behavior, it is not possible, because it is not yet implemented. The custom field filters for now only work with CPT and User type of results. Taxonomy meta only had been recently added to wordpress – it was previously only bypass supported by ACF.
Best,
Sooner or later this is going to be implemented for taxonomy term results as well, I am working on new features as fast as possible. Currently there is no way to do that via this plugin.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
-
This topic was modified 3 years, 10 months ago by
- AuthorPosts
You must be logged in to reply to this topic.