For those who want a solution this code will store the featured image url in the post meta when the custom post is added or updated. You then only need to grab the url from post meta in a loop by post id and meta name. This eliminates the myrid of calls to get the thumbnail id and then the url.
function add_slider_posttype() {
$labels = array(
'name' => _x( 'Slider', 'post type general name' ),
'singular_name' => _x( 'Slider', 'post type singular name' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New Slide' ),
'edit_item' => __( 'Edit Slide' ),
'new_item' => __( 'New Slide' ),
'all_items' => __( 'All Slides' ),
'view_item' => __( 'View Slides' ),
'search_items' => __( 'Search Slides' ),
'not_found' => __( 'No slides found' ),
'not_found_in_trash' => __( 'No slides found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Slider'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our slides and slider specific data',
'public' => true,
'menu_position' => 25,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' => true,
);
register_post_type( 'slider', $args );
}
add_action( 'init', 'add_slider_posttype', 0 );
function save_slider_meta($post_id) {
if(get_post_type( $post_id ) == "slider"){
$thumbnail_id = get_post_thumbnail_id( $post_id );
$url = wp_get_attachment_url( $thumbnail_id );
if (!empty($url)){
update_post_meta($post_id, 'slider_img_url', $url);
}
}
}
add_action( 'save_post', 'save_slider_meta');