WordPress Multi Post Thumbnails Return Image Src URL
0
up 1 down 0
Thank you for voting !

WordPress Multi Post Thumbnails Return Image Src URL



What is Multi Post Thumbnails ?

The WordPress MultiPostThumbnails is the extended WordPress class which adds the ability to add multiple post thumbnails to a post type. We can integrate this class through some Plugin installation or using manual process. This class even supports WP custom Post types for multi featured images.

The WordPress default function wp_get_attachment_url and wp_get_attachment_image_src delivers src url and image attribute values(in array) for default featured image.

Example of getting src url for default featured image


<?php
$id_post = "3452";
$thumbnail_id = get_post_thumbnail_id( $id_post );
$img_featured = wp_get_attachment_image_src( $thumbnail_id, 'full' );
echo $img_featured;
// Output full image URL of default featured image
// https://infoconic.com/infoconic_com/assets/uploads/example.jpg
?>


Example of getting src url for Multi Post thumbnails featured image


<?php
$id_post = "3452";
$imgid = MultiPostThumbnails::get_post_thumbnail_id('Custom-post-type-name', 'id-of-registered-multipostthumbnails', $id_post);
$img_featured_port = wp_get_attachment_url($imgid);
echo $img_featured_port;
// Output full image URL of Multi post thumbnail featured image
// https://infoconic.com/infoconic_com/assets/uploads/example-2.jpg
?>

Something To Say ?

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

*