How to customize item sorting options in AIT Directory+ theme
Quite handy, but customization is less straightforward. The support team behind it are extremely reluctant to help, especially when questions regarding customizations are asked, even though they can be very simple to answer.
One of the things I came across, is that ordering the items has limitations. Within the theme options (Item/Category Location Options), you can select to display 5, 10 or 20 results at the same time, and order them by Title or Date, ASC or DESC. These are severe limitations in my opinion.
– 5, 10 or 20 items is not only a very small amount, I generally prefer numbers that can be divided by 2, 3 and 4, so I can allow display of items to be trimmed to 1, 2, 3 or 4 columns, depending on the screen size.
– Sort by Title or Date is not always the desired solution. In my instance, I needed to list privately owned holiday houses for rent. By having the same order each time, some houses are always at the front, some always at the back. I was looking for equal exposure for all of them: random sorting. Different order each time someone visits the website.
Apparently, I am not the only one with this issue. I searched for solutions, and came across several Directory+ buyers, both on the AIT website and the Code Canyon website, where the theme is also sold. Without exception, the possibility is simply denied and questions on how to add this functionality are ignored.
I dug into the code, and found out that the answer is very simple! I’m posting it here, so hopefully others do not have to wonder anymore, and can add this simple piece of great functionality!
How does it work?
– All you need to do is make some changes to the file “@theme.neon”. It is located in the directory2\ait-theme\config folder.
– to change the number of items shown per page, go to the SortingDefaultCount block at line 680, as shown below. By default, the numbers are only 5,10,20. But you can simply add other numbers of your preference. These are then added in the Theme options and can be selected.
label: Number of Items
default: [5, 10, 20, 24, 36, 48, 60] help: "Number of items listed on one page"
– to add the random sort option, in the same @theme.neon file, go to the SortingDefaultOrderBy block at line 686, as shown below. By default, only “date: Date” and “title: Title” are there. Simply add the line “random: Random”. Once saved, the “Random” options appears in the Theme Options
label: Order By
help: "Select order of items listed on page"