WP_Query function for custom post type

The $post variable inside your function does not point to anything. You are declaring global $wp_query (which you are not actually using), but not global $post.