Fires before the Filter button on the Posts and Pages list tables.
Description
The Filter button allows sorting by date and/or category on the Posts list table, and sorting by date on the Pages list table.
Parameters
$post_type
string- The post type slug.
$which
string- The location of the extra table nav markup:
'top'
or'bottom'
for WP_Posts_List_Table,'bar'
for WP_Media_List_Table.
Source
do_action( 'restrict_manage_posts', $this->screen->post_type, $which );
The example below eliminates the need for
parse_query
when filtering based on taxonomy. It uses the taxonomy slug as URL parameter, just like WordPress does out of the box. The example adds filter dropdowns for two taxonomies, and allows for boolean AND filtering.Use this hook to add a custom taxonomy filter for your post table,
To add a custom filter based on a meta field for example, you can build a custom dropdown filter,
next we need to ensure the admin query returns the correct set of filtered posts by hooking onto the ‘parse_query’ filter,
To build more complex meta field queries, lookup the documentation for the
WP_Meta_Query
object.Use this hook to add a custom taxonomy filter for your post table,
to ensure the post table is correctly filtered, the post query needs to be modified to filter the selected term. This is done by hooking the
'parse_query'
filter,