How to get secondary image url from a custom post in wordpress

I am using Multiple Post Thumbnails plugin to add secondary image in a custom post called ‘branding’. I have added the image in back end. I need to get the image url for each post in that custom post type. I have used the code below.

$arr= array("posts_per_page" => "-1","post_type" => "branding" );
       $posts = get_posts($arr); 
            foreach($posts as $data){  

            //secondary featured image
$custom = MultiPostThumbnails::get_post_thumbnail_id('branding', 'secondary-image',$data->ID); 
$customs=wp_get_attachment_image_src($custom,'post-secondary-image-thumbnail'); 
$thumb = wp_get_attachment_url( get_post_thumbnail_id($data ->ID) );
echo $customs[0];
}

But I couldn’t get anything. How can I get it. Any error in the above code?
Please help me to resolve this.

Thanks

Read more here: How to get secondary image url from a custom post in wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *