Hi,
Is there a way to sort by custom field?
I have a HTML table with each TH being the custom field label, and each row being a custom post type’s custom field values.
Thanks,
Steve
Thanks John.
My theme’s front-page.php
contains the code here: http://pastebin.com/VfMKBjq2
I don’t understand how to make something like <th>Model:</th>
into a hyperlink which sorts by custom field model
.
Ad the bottom of this page https://www.advancedcustomfields.com/resources/query-posts-custom-fields/ there is a section on Dynamic $_GET parameters. Basically you’d have to generate your own links adding something like ?model=XYZ
to each URL and then set up a pre_get_posts filter to alter the WP query for the page to get what you want and sort it.