Display Grouped Posts
An Advanced Guide for Pro users to help them through step-by-step on how to display lists of information grouped by a field.
In this example
We'll take a list of company employees, and display them in an alphabetical ordered list with the Last name in Ascending order, and include a line with first letter of the last name.
Step by step guide
First create your Field Group with the fields, in our case it's text fields for Last Name and First Name assigned to a Custom Post Type (CPT) called Employees.
Visit the Advanced Views tab in WordPress backend.
Create your View
Click the Add New button to add a new View and Enter a Name for your View.
Click the Add Field button in the Fields section. Then select the target Group from the list and the Field from the dropdown. Continue to Add Fields until they've all been assigned. in our case we're only adding two fields, Last Name and First Name.
Click on the Publish button to save and publish your View.
Optional — Continue editing your View, switch to the Template tab and copy the Default Template into the Custom Template field, add in a comma, so names are displayed nicely. e.g. Doe, John
Create your Card
Use the "Create card" link in the right sidebar of your View, or Simply go to Card top tab.
Click the Add New button to add a new Card, enter a Name for your Card.
On the General tab you should choose Sort by "Meta value", with the Sort by Meta Field Group to the one containing the name fields, in our case it's 'Employee (Names)'. Select Sort by Meta Field and the field of your choice, in our case it is 'Last Name (text)' with Sort order "Ascending" i.e. alphabetical.
Switch to Advanced tab and scroll down to Custom Data and insert the function snippet below. Replace your field name for "last_name".
Switch to the Template tab, and copy the default template into the Custom template field below it.
Modifying from line 5 -> 8.
Publish or Save your Card and copy the shortcode into place.
Remember to fill out some information and create your posts.
Last updated
Was this helpful?