Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Help with showing correct posts on load
This topic contains 9 replies, has 2 voices, and was last updated by Ernest Marcinko 3 years, 5 months ago.
- AuthorPosts
- June 14, 2020 at 9:28 am #27848
When visiting an archive page on my website, the filter always defaults to the region: “Brisbane” when in this case I want it to show “Gold Coast” (see link). How do I get it to do this when visiting the archive page?
https://mychoiceschools.com.au/queensland/qld-regions/gold-coast/
More details: currently using an Elementor template called “QLD School Archive Page” I have followed the docs on how to set-up correctly and all works well apart from this.
Any help would be appreciated. Thanks.
June 15, 2020 at 9:55 am #27855Hi,
Try turning on the auto-populate feature with these settings (empty phrase): https://i.imgur.com/g7Sl4NE.png
Best,
That should very likely do the trick, by triggering the search with the selected default options.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
June 15, 2020 at 10:26 am #27857Hi Ernest,
Thanks for your reply. Unfortunately, that didn’t seem to work. Would you be able to take another look at it for me?
Thanks,
LiamJune 15, 2020 at 11:52 am #27859You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
June 15, 2020 at 11:56 am #27861Hi Ernest, sorry I was fiddling with some things. It should be back now.
June 15, 2020 at 12:02 pm #27863Thanks! I just tried that page, and it works on my end, the search triggers and enables with the default filters configuration, see video: https://youtu.be/tq619ASHYRY
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
June 15, 2020 at 12:05 pm #27864But it should show “Gold Coast”. See image below
June 15, 2020 at 12:33 pm #27870Oh, I see what you mean now.
The only way to do that is via custom coding. The filter value needs to be conditionally set via the API.
Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
add_filter('asp_pre_get_front_filters', 'asp_change_tax_filter', 10, 2); function asp_change_tax_filter($filters, $type) { $taxonomies = 'qld_regions'; // Comma separated list of taxonomies // --- DO NOT CHANGE ANYTHING BELOW --- if ( is_archive() ) { $taxonomies = explode(',', $taxonomies); foreach ( $taxonomies as $taxonomy ) { $taxonomy = trim($taxonomy); foreach ($filters as $k => &$filter) { $term_id = get_queried_object()->term_id; if ($type == 'taxonomy' && $filter->data['taxonomy'] == $taxonomy) { $filter->unselect(); $filter->select($term_id); } } } } return $filters; }
Unfortunately I cannot guarantee that this is going to work at all, but it should be a good start.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
June 15, 2020 at 12:51 pm #27872That’s fixed it! A really great plugin by the way, thanks!
June 15, 2020 at 12:53 pm #27873You are very welcome, and thanks for the kind words 🙂
If you don’t mind, I will close this topic soon and mark it as resolved, feel free to open another one if you have other questions or issues.
If you like the plugin, feel free to rate it on your codecanyon downloads page, it’s greatly appreciated.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.