Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Category ordering on the "Frontend Search Settings" doesn't work
This topic contains 12 replies, has 2 voices, and was last updated by alekosk 5 years, 4 months ago.
- AuthorPosts
- January 18, 2018 at 3:34 pm #16370
Hi,
I am creating the Frontend Search Settings and I add categories in the order I want them to appear. However the order is not kept.
See attached file.Instead of the “Technology” categories with its subcategories to be first, in the frontend search box they are last!
How to fix this? I tried to clear cache, forced inline CSS, etc.. but nothing.
Thanks
Attachments:
You must be logged in to view attached files.January 18, 2018 at 3:35 pm #16372Also as you see the subcategories are not ordered in the order they are in the settings..
January 18, 2018 at 3:54 pm #16375Hi,
I quickly tried to re-create the issue on my test server, but it seems to be respecting the order I give it.
Does the preview window on the back-end shows the same order? If it shows correctly, then it is very likely a cache related issue.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 18, 2018 at 3:56 pm #16376Hi Ernest,
No, both previouew and front-end show incorrect order..
They do not follow the order of the settings at all 🙁Cleared my cache, opened in incognito window, also cleared the cache through Ajax Search Pro settings but nothing.
anything else?January 18, 2018 at 4:23 pm #16379Hi,
Are all of the categories selected individually?
I did a further tests, but everything looks okay here. It should also correct if sub-categories are dragged under the wrong main category, but even then, the order is kept. From the screenshot, I don’t think this is the case.I have also looked up the source where the terms are printed, and that part looks correct, it uses the WordPress core get_terms(..) function, and the argument is set to respect the order of the given term IDs.
Can you grant me FTP and Back-end access to a temporary test environment where I can test this? I feel like this is something specific, or maybe there is some sort of 3rd party filter that may alter the get_terms(..) function output. It could also be an unknown bug yet, I honestly don’t know, as I’m not able to re-create the problem for some reason.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 18, 2018 at 4:45 pm #16387Hi Ernest,
Yes all of them selected individually.. Its weird that in the backend I see the correct structure but on the front end it’s messed..
FTP Access I am not sure, back-end access could be possible…how to grant u the access?
January 18, 2018 at 8:11 pm #16391Hi,
You can edit your initial post and use the secure fields, or mark your next reply as private, or upload a .txt file with the details, whichever suits you.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 19, 2018 at 9:23 am #16392You cannot access this content.January 19, 2018 at 11:31 am #16397Hi Alekos,
Thank you, I was able to log-in and do some tests.
I believe there is something affecting the built in get_terms() function. I have tested the order which the search requests the categories, which is the correct order:
69, 3, 2, 42, 43, 49, 44, 45, 46, 47, 40, 38, 39, 70, 37, 63, 64, 51, 67
..but the functions returns them in this order (this is what is then outputted):
2, 3, 40, 39, 38, 37, 42, 43, 44, 45, 46, 47, 49, 51, 69, 70, 63, 64, 67
This should not be happening, and I have no idea why that function returns the incorrect order, and it would be probably a nightmare to debug it.
Instead, I have quickly made a custom filter function, that replaces the current method of getting the terms bulk, at once, by getting them one-by-one, and then merging them to an array. Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!
This should hopefully fix the problem.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 19, 2018 at 11:43 am #16399Ok, that did the trick!!
Thanks alot Ernest, much appreciated!!
January 19, 2018 at 11:49 am #16400You cannot access this content.January 19, 2018 at 12:40 pm #16401You cannot access this content. Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
January 19, 2018 at 1:25 pm #16403You cannot access this content. - AuthorPosts
You must be logged in to reply to this topic.