[Résolu] Sorting Archive Tables by Clicking Column Heading
This support ticket is created Il y a 2 années et 10 mois. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
What is the link to your site?
Current in developer mode, if access is required I'll provide it
I've been trying to setup a simple archive for some CPT's and display them in a table. But besides the block editor being quite clunky and not seeming to have an option for sortable table headers, when I apply the normal shortcode it doesn't seem to work either:
Thank you for contacting us and I'd be happy to assist.
Your observation is correct and the sortable header table feature is not available for WordPress Archives.
To achieve something similar, you'll need to create the archive using a regular table and then apply some custom script, that can perform the sorting on the front-end.
I hope this helps and For more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors: https://toolset.com/contractors/
Ok, fair enough if it's not a feature, although it REALLY should be surely? If it could be put forward for development I'd highly recommend it. It is a basic function of tables after all.
I'll sort out a custom sorting script for it, but that post you've directed me to doesn't actually show the links to the scripts you recommended, it just says hidden link, so I'm assuming it's for those involved in the conversation only or something?
Before I waste ages going to find some compatible ones myself, could I get those recommendations to investigate please?
Thanks, I'll take a look over them. I was already looking into a Bootstrap-focused solution anyway and the mdbootstrap option may well be the one.
For anyone else reading this, I'll post the solution I end up using, but Datatables and FooTable are also viable options. In the mean time, anyone interested should check out this, admittedly fairly old thread, but it gets the job done:
Note: This isn't a still needing assistance situation, I just wanted to post a followup with a solution for anyone viewing this ticket. The site made me tick the reopening tickey box but support please just close it off.
I've spent a fair bit of the day checking into these options and whilst I appreciate the ones suggested by Waqar, I'd advise against them because the mdbootstrap one requires a pro license and tablesorter hasn't been updated in nearly a year.
In the end I've gone with FooTable as all I've had to do is download the standalone version (the bootstrap one is an option too but I found the standalone one better suited to my setup) and then enqueue the scripts like this:
In my theme's functions file (I created a chid theme but you don't need to). Then on the archive page just add this to the Loop Editors JS window:
jQuery(function($){
$('.table').footable();
});
After that it's installed and good to go. You can follow the usage instructions on their website:
hidden link hidden link
The only tiny issue I ran into was a known bug that has been addressed and is a simple copy and paste to fix and is detailed here:
hidden link
FooTable has way more features than I'm ever going to need but it gives me the flexibility to get things sorting properly and the amazing feature of having columns be mobile responsive and disappear at certain screen sizes and replaced with a dropdown!
Oh, and make sure you have Font Awesome running on your front end to get the icons to show up properly.
I hope that this helps somebody else out and I strongly encourage Toolset to include similar features soon.