Support

Account

Home Forums Backend Issues (wp-admin) Filter by Radio Button Value in Admin Reply To: Filter by Radio Button Value in Admin

  • I’ve been working with this same code, but to filter “Coupons” by “Service Type”, where service_type is a custom post type that is part of each coupon in the form of a relationship field. The one thing that i did that made this work is to add:

    $query->query_vars['meta_compare'] = 'LIKE';

    in the wpse45436_posts_filter function so it should read like this:

    function wpse45436_posts_filter( $query ){
        global $pagenow;
        $type = 'post';
        if (isset($_GET['post_type'])) {
            $type = $_GET['post_type'];
        }
        if ( 'sp_people' == $type && is_admin() && $pagenow=='edit.php' && isset($_GET['ADMIN_FILTER_FIELD_VALUE']) && $_GET['ADMIN_FILTER_FIELD_VALUE'] != '') {
            $query->query_vars['meta_key']     = 'sp_people_status';
            $query->query_vars['meta_value']   = $_GET['ADMIN_FILTER_FIELD_VALUE'];
            $query->query_vars['meta_compare'] = 'LIKE';
        }
    }

    Hope this works for you.