I have created a custom wp list table which displays posts according to my custom WP_Query,
I need to implement a category filter like the one shown below.
I need to display all categories as a drop-down and on selecting a particular category, I want to somehow apply this category filter to my wp_query,
Here is my WP_Query.
$wp = new WP_Query(
array("post_type" => "post",
"post_status" => $status,
"meta_key" => "sc_imported",
"meta_value" => true,
"posts_per_page" => $per_page,
"paged" => $current_page,
"orderby" => $_REQUEST['orderby'],
"order" => $_REQUEST['order']
));
- How to implement drop-down,
- how to apply this category filter to the WP_Query.
Use this function wp_dropdown_categories( $args );. It will create dropdown for categories.
Please read here for complete function details.