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

WordPress Multi Post Thumbnails Return Image Src URL



What is Multi Post Thumbnails ?

The MultiPostThumbnails is the expanded WordPress functionality that provides the ability to add multiple thumbnails to any post. cusWe can implement this class by downloading a Plugin or using manual process. This class also support WP custom Post type.

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 *

*