In this example, you can see how to add the IP column and it’s simple because the IP info is already stored in the Dashboard DB.
However to create columns that will show custom info that is not stored in the MainWP Dashboard database, such as server admin URL, Referring Domains…), first, you need to create custom site fields on the Site Edit page and enter the values, after that, you can use those hooks to show the data in the table.
Regarding the sorting ability of custom columns, there is another filter that can be used to add the column in the array of sortable columns, for example the IP Address column that we created in the previous example will be sortable if you use this snippet:
Regarding the search ability, the Search feature of the Manage Site table, but default, includes all data that is in the table. Maybe I am missing something in your setup. Can you please provide me with more details?
I’ve added your code to be able to sort on the custom column. After that the sort icons (ascending / descending) appear but when I try to sort on the custom column the table is not sorted. We’re using MainWP version 4.4.1 and WP 6.2.
Searching for data used in the custom field is not working. We added this custom field via extensions → Pro Reports → Tokens and added some data in the custom field for some clients. When we search on the data we get the message “No websites found” and a few seconds after this search all websites are shown again.
I’ve tested this code as well as I’m showing the IP in my table too. It does show the sort up/down icons, but it doesn’t sort anything.
I also tried to find the filter in the docs on mainwp.dev, but couldn’t find it there.
I can confirm changing value for “Optimize for shared hosting or big networks” to “Off” makes it possible to sort the custom fields. But the loading of the sites table is very slow because of this. How can we improve the loading time?
The loading time is dependent on the performance of the server.
Please take a look at our help document for minimum and recommended system requirements, including some general guidelines for Dashboards with higher child site count: