How to customize item sorting options in AIT Directory+ theme

article header image

For one of my clients, I recently built a WordPress website based on the AIT Directory+ theme. Directory+ is a theme which will allow you to create all kinds of location-bound items (shops, companies, venues, etc.) and display them on a Google map as pins which can be clicked to read more info on the item, kind of like Google Maps itself.

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
type: select
selected: 5
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
type: select
selected: date
date: Date
title: Title
random: Random
help: "Select order of items listed on page"

foto Boris Hoekmeijer
My name is Boris Hoekmeijer, I'm a webdesigner and graphic designer.
I sometimes run into a problem for which I have to find my own solution because Google just won't tell me. That's when I climb behind my mechanical keyboard, and fire away until a tutorial materializes. One of the great things about the web: we can all help each other!
If this article has helped you, or if you have anything to add or ask, please leave a comment or share the post.

© 2017 ★ Published: April 7, 2017

  • Francisco says:

    Hi Boris, we are trying to modify the order of the search results in ait-directory2, by a custom postmeta value, but we do not have any idea of how to do that, do you have any suggestion?


    • Boris Hoekmeijer says:

      Hi Francisco,
      can you explain more? Your description is too vague for me to be able to help you.

      • Francisco says:

        Hi, we added a postmeta key to every item created, I want to order the search results using the values of that meta key, we do not know if that is even possible, what do you think?, thanks a lot for your answers, we love you lol.

        • Boris Hoekmeijer says:

          That would require some custom coding, I have no idea what that should look like. I know support at AIT will tell you to hire a developer.
          Perhaps if you explain which end result you are trying to accomplish, instead of the technical way to get there (i.e. using a custom meta key), I can help you solve the puzzle.

  • Andre says:

    Good Day Boris

    Does this still work?

    I have tested these settings and it is not working with our version of AIT Directory+

    • Boris Hoekmeijer says:

      Hi Andre,
      i just updated to the latest version (2.36), and it still works. I did get a 404 error after updating, but that disappeared after resaving permalinks settings and clearing the cache. Can you explain where exactly things are going wrong?

Leave a Reply

Your email address will not be published. Required fields are marked *


Deze website maakt gebruik van cookies. Hoe zit dat?

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.