Incorrect Use of wpdb::prepare()
You should try to replace the meta_value = $list->ID part with the placeholder meta_value = %d. Then use the following: $subscriber_count = $wpdb->get_var( $wpdb->prepare( $q, $list->ID ) ); where the input argument $list->ID will be treated as an integer (signed). From the Codex: The query parameter for prepare accepts sprintf()-like placeholders. The %s (string), %d … Read more