Fixed custom post types and moved thumbnail code