wordpress custom filter for the edit.php custom posts list
-
I have a custom orders posts and i wish to implement an additional filter for the list view (a select drop) in the admin menu.
I have been messing with this for hours but couldn’t find a solution. i wish to filter the posts by several meta keys and values and by post date this is the code im using for this matter
add_filter( 'parse_query', 'order_posts_filter' ); function order_posts_filter( $query ){ global $pagenow,$wpdb; $type = 'post'; if (isset($_GET['post_type'])) { $type = $_GET['post_type']; } if ( 'orders' == $type && is_admin() && $pagenow=='edit.php' && isset($_GET['ADMIN_FILTER_FIELD_VALUE']) && $_GET['ADMIN_FILTER_FIELD_VALUE'] != '') { $query->query_vars['post_date'] = $_GET['ADMIN_FILTER_FIELD_VALUE']; } if ( 'orders' == $type && is_admin() && $pagenow=='edit.php' && isset($_GET['ADMIN_FILTER_STATUS_VALUE']) && $_GET['ADMIN_FILTER_STATUS_VALUE'] != '') { $query->query_vars['meta_key'] = 'order_status'; $query->query_vars['meta_value'] = $_GET['ADMIN_FILTER_STATUS_VALUE']; } return $query; }
at the moment what im getting is that only one filter is applied.
What am i doing wrong here ? my $_GET parameters are working as expected and i am getting the relevant data from the select boxes.
thanks
- The topic ‘wordpress custom filter for the edit.php custom posts list’ is closed to new replies.