Filters are based on user metadata. All the fields when editing a user in WordPress are that user’s metadata. Name, email, website, bio…
The default user metadata isn’t really something that users can be filtered by, those are all unique to every user.
Some “user profile” related plugins create their own user metadata fields, and some plugins allow you to create custom user metadata fields for whatever you want.
If you already know how to add custom fields for users, you can skip to the section about Setting up Filters, and if you don’t know then below is an example of doing that using one of the most popular plugins for custom fields.
Adding Custom Fields
In this example we’ll add 2 custom fields (age and country) using the Advanced Custom Fields plugin.
You can access the Custom Fields just above the Authors List in the admin menu.
In the top left corner you’ll see a button Add New, click that to add a new field group.
The settings are separated into 2 sections, Fields and Settings
In the Fields section add 2 simple fields, one a number field with the name Age and the other a text field with the name Country
In the Settings section set User Form for “Show this field group if” field.
Save the changes and then go to edit a user (WP admin > Users). You will see the 2 new fields there.
Your users also see those when editing their profile. Populate it for a few users and move to the next section.
Setting up Filters
When editing a list you’ll see the Search & Filters in the tabbed navigation, click that and you’ll see the following:
Check the checkbox for Filters – Enable to enable it and you’ll see new options show up.
Click the Add New button to add a new filter. You will see 3 fields show up:
Meta Key is the key/name of the user meta field.
Label is the title that’s shown above the filters in the front-end.
Filter Type is where you can select what kind of a filter it is, is it a select box, radio input, number range…
Following from the example from earlier in the documentation let’s add the 2 filters for age and country. For age we’ll add a number range filter type and for country we’ll add checkboxes
Now go ahead and click the Save Changes button and go to the page where you have this authors list shown. You should see something like this:
Your visitors can use those filters to narrow down the list of authors.
That covers the documentation for the Filter functionality. If you have any questions or run into any issues/bugs, feel free to contact us.