Hi @jseroskie,
Thank you for reaching out; I’ll be happy to help!
If you actually want to sort solely on your “Year” column, there’s no need for parameters or commands, since you can simply change the default order in the backend editor:
- Edit your table and scroll to the “Table Content” section.
- Double-click on the column header (A, B, C, etc.) of the column you wish to sort on until it’s in descending order.
- Save your table.
However, I assume you want to make sure that your second, associated dimension—the “Issue” column—stays sorted chronologically at all times. For this, we do need to add Shortcode parameters and Custom Commands, you’re right:
- Edit the page or post on which your table is placed, then select the Shortcode or TablePress table block.
- Add the parameter
datatables_datetime="MMMM" either to your Shortcode (so it reads [table id=XYZ datatables_datetime="MMMM" /]) or, for the TablePress table block, to the “Configuration Parameters” field in the “Advanced” section in the block editor’s sidebar. This assures that TablePress will identify month names as such.
- Edit your table and scroll to the “Table Features for Site Visitors” section.
- Paste this code into the “Custom Commands” field:
columnDefs: [ { type: "date", targets: [ 0 ] }, ], order: [ [ 1, "desc" ], [ 0, "desc" ] ], (with “0” referring to the first column).
This will first sort your table by year in descending order and then, within each subset, by issue in descending order.
By the way, if you intend to regularly update or re-import that table’s data, you might want to look into our premium Automatic Periodic Table Import module.
Let me know if that helps or if you need further assistance 🙂
Best wishes,
Tim
Thank you sooo much for the detailed answer. Got it sorting the way I want. You have a beautiful product. I am using it on two websites now. Powerful yet easy to use.
This particular table is an archive which will not be updated again. However I have a dozen or more tables on two websites which are actively maintained. Thank you for a really terrific and thoughtful design.
Hi @jseroskie,
Thank you for your reply and for the praise! That’s lovely—I’m happy to hear that we got your sorting sorted 😉
Best wishes,
Tim
P.S.: In case you haven’t, please rate TablePress in the plugin directory. Thanks!