Posts table filters
filters option in Posts Table Pro allows you to display dropdown lists above your table which allow users to filter (i.e. search) the table by selecting an item from the list. For example, you can use the categories filter to select a category from the list – this will filter the table to show posts from that category.
Note: This page covers the options for letting your users filter the table to narrow down the list of posts. If you want to create tables listing specific posts based on their category/date/tags etc. (i.e. perform a filter before the table first loads), check out this article instead.
How to add filter dropdowns above the table
You can enable filters for:
tags and any custom taxonomy. At the present time, you cannot enable filters for a custom field.
To show filters based on the contents of the table, add
filters="true" to the Posts Table Pro shortcode. This will show all filterable columns as filters above your table.
This example would show categories and tags as search filters:
[posts_table columns="title,categories,tags" filters="true"]
To specify which filters are shown (regardless of the columns displayed), you can list the filters to be included, e.g:
[posts_table columns="image,title,content" filters="categories,tax:my_taxonomy"]
The filters are displayed above the table by default, but if you have positioned the search box below the table, then the filters will also appear below the table.
Can I show the filters before the table loads?
Unfortunately not. The filters can only be appear above the table. They are designed to refine the items in the table, and not to perform a filter before the table first loads.
Can I list categories and sub-categories as separate filter dropdowns?
Posts Table Pro lists all categories (or taxonomies) in a single dropdown list.
The list is nested/hierarchical so that you can see which are the parent categories and which are child categories.
Can I control the order of the dropdown items?
The filter dropdown lists are ordered alphabetically and there are no options to change them.
If you’re using the filters to list something where alphabetical sorting isn’t appropriate (e.g. dates), then you could add numbers before each item to control the order. For example, if you’re using categories to filter by month, then you could name your categories ’01 – January’, ’02 – February’, and so on.
Can I rename the filters?
If your filters also appear as a column in the table, then you can rename the column and this will also rename the filter.
If your filters are not columns in the table, then the filter name is set automatically (e.g. Tags, Categories, or the name of your custom taxonomy).
Can I filter by custom fields?
Posts Table Pro doesn’t come with custom field filters because this is not how custom fields are intended to be used. We recommend that you store this extra data as custom taxonomies rather than custom fields, as these can be filtered.
Custom fields are designed to store unique data, and as such they’re not supposed to be filterable. In contrast, custom taxonomies are like categories and are designed to group and sort posts and other WordPress post types.
If you don’t know how to create custom taxonomies then we recommend the Custom Post Type UI or Toolset Types plugin. These let you create custom taxonomies for any post type in WordPress. You can then list the custom taxonomies and their terms as filter dropdowns above the table.
Can I add checkbox filters?
Posts Table Pro only comes with dropdown list filters, and there’s no feature to add check box filters instead. The dropdown filters are very flexible and you can add as many as you like, instead of using checkboxes.
The categories filter isn’t showing
If the categories filter isn’t showing, then it may be that you are displaying custom post types in your table.
The categories filter only appears when you are listing normal WordPress posts and does not work for custom post type categories (e.g. event categories or document categories) because these are actually custom taxonomies and not categories.
If you are categorising your custom post type, then you need to create a taxonomy filter instead of a categories filter. For example, this shortcode will add a filter for a taxonomy with the slug ‘document_category’: