Skip to content
Advertisement

Trying to sort by price but not working in WordPress

I have a function that group the products and I want to sort in ascending order by the price. I even tried to use “sort() function but display any output. I have several options with Array_multisort(), asort().

JavaScript

The function that calls the DISPLAY_MODEL function

JavaScript

From the page template, I called the function add_homes_for_home_types() The code below:

JavaScript

I will appreciate if anyone can help out. I have tried to handle the sorting at each level but not working. That is why I tried to look elsewhere.

Thank you

Advertisement

Answer

You can sort the output using JQuery, it is really simple and straightforward. The code below will only work if you make some adjustments in your function. Don’t worry, I will guide you to achieving that.

JavaScript

Back to your function, look for this line and replace with this; (you have the line in the first function pasted above)

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement