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

  • Frank J. says:

    Some months later …

    We had a somewhat general discussion about AIT Themes in March, Boris. Things didn’t change since then: I still wish there was a user forum where AIT Directory Theme user could exchange problems, solutions and ideas. We should set one up.

    Overall the AIT Directory themes are pretty good — but e. g. running into the issue of the locked header maps (one has to unlock the front end map for scrolling each time a page is loaded) I had to open a support ticket.

    A user forum would help in such cases (I am sure many had the same issue before) or a good documentation. Both are not provided by AIT Themes.

    Are you still using AIT themes?

    Cheers, Frank

    • Boris Hoekmeijer says:

      Hi Frank,
      yes, I’m still using AIT themes. I set up this website for one of my clients. They do not have the budget to start over with a new theme, if there even is any that would suit this purpose.
      It’s working okay, and after every update I make the manual changes to some of the theme files again, but it works.
      Support has not been bad, I’ve had one or two minor issues to which they replied within a couple of hours.
      So in all, it’s not bad. But I agree with you that a forum and extensive documentation would be a great benefit.

      • Frank J. says:

        Thanks for your answer, Boris.

        What do you think: Should we create a AIT Themes Usergroup? I would be willing to share my experience in a protected environment (members only).

        Cheers, Frank

        • Boris Hoekmeijer says:

          Hi Frank,
          I suppose we could, there might be more of us out there looking for AIT-answers :-). What did you have in mind? A LinkedIn group or on some other platform?

          • Frank J. says:

            No, not Linkedin or other platforms that require a membership in another group.

            I think we should setup a site using an AIT theme (Directory or Multi-Author Blog) and integrate a classical forum.

          • Frank J. says:

            You got mail, Boris.

  • Frank J. says:

    Hi Boris,

    thanks your ideas. I like the concept of sharing thoughts and knowledge on such a basis — although AIT support helps out I also wish things would be a bit smoother (and the documentation would be better) …

    I think I will try what you propose in a few days when my Directory+ website will be ready and have more content. For now I wanted to ask if your solution could be used with a child theme.

    If not the changes would be overwritten with the next Directory+ update.

    Any ideas?

    Cheers, Frank

    • Boris Hoekmeijer says:

      Hi Frank,
      you are absolutely right. In fact, I did create a child theme for Directory+ for that reason. It’s been working just fine.

  • Evan says:

    How do I access the directory2 folder?

    • Boris Hoekmeijer says:

      Hi Evan,
      you can do that via FTP. Access the folder, and edit the files with a HTML or text editor. I recommend Sublime Text, but there are other good ones as well. Good luck!

      • Evan says:

        Thanks for your swift response. Is there a way to do this from the wp editor? I don’t even see the @theme.neon file. I see a @theme.php.

        • Boris Hoekmeijer says:

          I’m not sure if that is the same file, I do not see it in my theme. It’s likely that the .neon files are somehow accumulated to PHP files automatically in the theme upon changing. But I cannot check within the default WordPress Editor, as I always disable it so my clients cannot accidentally remove things that shouldn’t be removed :-).
          Is there no way you can get FTP access? Perhaps you are able to log on to the hosting account? Usually that also includes a File Explorer with which you can leaf through the theme and download the necessary files.

          If you do a subsequent search (that would also work if you copy the contents of @theme.php to for instance notepad in Windows), you can check whether the piece of code I’m referring to is in the file. If so, odds are that changing that file will do the trick.

          Does that help you further along?

          • Evan says:

            Yes, I was able to access theme.neon through cPanel. I’ve added the random dropdown selection, now I just need the items to randomize differently on each load. Any thoughts on how to do that? as of right now they are shuffled the same way each time.

          • Boris Hoekmeijer says:

            I’ve also experienced what you describe, and found out that it has to do with caching. You can check by doing a search from a different machine in your network, or if that doesn’t work, a machine on a different network (so you have a different public IP address). I bet you will get a different order then.

          • Evan says:

            I fixed it. Had to change “random: Random” to “rand: Random”

            Thank you so much for your help!

          • Boris Hoekmeijer says:

            Glad you got it working, you’re welcome!

  • 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 *