Hi there,
I'm working on a catalog for a Continuing Education department at a college of art and design. Using the Loop Wizard, I've created a view with a table that has five columns:
+ Course Name [String]
+ Course Number [String]
+ Category [String]
+ Start Date [Date]
+ End Date [Date]
My table's columns are supposed to be interactive and, when clicked, sort the table in either ascending or descending order. The columns with a data type of "String" are in fact sortable, but the columns with a data type of "Date" are not. Can I make my table sortable by the date fields?
You can see the table on this webpage:
hidden link
Thank you!
Saul
Hi, are these start and end dates custom fields? Are they created in Types? Are the start and end dates applied to the posts shown in the table results (as opposed to some related post)?
If the answer to those questions is "yes" then it should be possible to sort based on those date columns. If the answer to any of those questions is "no" then it's a bit more complicated and I would have to take a closer look.
Christian,
Thanks for your response. The answer to all of your questions is indeed "yes." Here's the code for the table header snippet:
<thead>
<tr>
<th>[wpv-heading name="post-title"]Course[/wpv-heading]</th>
<th>[wpv-heading name="types-field-course-number"]Course No.[/wpv-heading]</th>
<th>[wpv-heading name="post-taxonomy"]Category[/wpv-heading]</th>
<th>Start Date</th>
<th>End Date</th>
</tr>
</thead>
I've attached a screenshot for greater context (Screen Shot 2019-03-18 at 21.07.51.png). Note: when I added a [wpv-heading] to the Start Date field, the sort order was crazy. I've attached a second screenshot (start date ascending order - not working.png).
S
Okay you'll have to apply a wpv-heading to the Start Date column header, as well as the End Date header. Otherwise, they won't be sortable. Verify the start and end date field slugs in wp-admin to be sure you're using the correct spelling and punctuation in the slug names. If that's not the problem, try a few troubleshooting steps:
- Temporarily deactivate all plugins except Types and Views, activate a default theme like Twenty Nineteen, and test again
- If the problem is resolved, reactivate your theme and other plugins one by one until the problem returns
- If the problem was not resolved, I'll need to take a closer look. Please provide login credentials in the private reply fields here.
I found the solution to the problem. Here's the wrong code I was using for the header:
<th>[wpv-heading name="course-start-date"]Start Date[/wpv-heading]</th>
Here's the correct code:
<th>[wpv-heading name="types-field-course-start-date"]Start Date[/wpv-heading]</th>
I manually entered the name attribute, and it takes a specially formatted name, not the custom field slug. Christian, is there a reason why the [wpv-heading] shortcode uses a variant of the custom field slug instead of just the custom field slug as is customary elsewhere in the interface?
Saul