do_action( 'restrict_manage_posts', string $post_type , string $which )
Fires before the Filter button on the Posts and Pages list tables.
Description 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 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 Source
Changelog Changelog
Version | Description |
---|---|
4.6.0 | The $which parameter was added. |
4.4.0 | The $post_type parameter was added. |
2.1.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
To add a custom filter based on a meta field for example, you can build a custom dropdown filter,
Expand full source codeCollapse full source code
next we need to ensure the admin query returns the correct set of filtered posts by hooking onto the ‘parse_query’ filter,
Expand full source codeCollapse full source code
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,
Expand full source codeCollapse full source code
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.Expand full source codeCollapse full source code
Use this hook to add a custom taxonomy filter for your post table,
Expand full source codeCollapse full source code
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,Expand full source codeCollapse full source code