-
Notifications
You must be signed in to change notification settings - Fork 32
Retrieving data in a theme
Ankit Pokhrel edited this page Sep 15, 2016
·
6 revisions
- To get featured images of specific post
if( class_exists('Dynamic_Featured_Image') ) {
global $dynamic_featured_image;
$featured_images = $dynamic_featured_image->get_featured_images( $postId );
//You can now loop through the image to display them as required
}
- To get featured images in a post loop.
<?php
while ( have_posts() ) : the_post();
if( class_exists('Dynamic_Featured_Image') ) {
global $dynamic_featured_image;
$featured_images = $dynamic_featured_image->get_featured_images( );
//You can now loop through the image to display them as required
}
endwhile;
?>
- The data is returned as an array that contain the thumbnail url, full size url and attachment id of the selected images.
array
0 =>
array
'thumb' => string 'http://your_site/upload_path/yourSelectedImage_thumbnail.jpg' (length=60)
'full' => string 'http://your_site/upload_path/yourSelectedImage_fullSize.jpg' (length=69)
'attachment_id' => string '56' (length=2)
1 =>
array
'thumb' => string 'http://your_site/upload_path/yourSelectedImage_thumbnail.jpg' (length=60)
'full' => string 'http://your_site/upload_path/yourSelectedImage_fullSize.jpg' (length=69)
'attachment_id' => string '57' (length=2)
2 => ...
- To get featured images of specific post
if( function_exists('dfi_get_featured_images') )
$featuredImages = dfi_get_featured_images($postId);
- To get featured images in a post loop.
<?php
while ( have_posts() ) : the_post();
if( function_exists('dfi_get_featured_images') ) {
$featuredImages = dfi_get_featured_images();
//Now, loop through the image to display
}
endwhile;
?>
- The data is returned as an array that contain selected image, full size url of the selected image and attachment id.
array
0 =>
array
'thumb' => string 'http://your_site/upload_path/yourSelectedImage.jpg' (length=50)
'full' => string 'http://your_site/upload_path/yourSelectedImage_fullSize.jpg' (length=69)
'attachment_id' => string '56' (length=2)
1 =>
array
'thumb' => string 'http://your_site/upload_path/yourSelectedImage.jpg' (length=50)
'full' => string 'http://your_site/upload_path/yourSelectedImage_fullSize.jpg' (length=69)
'attachment_id' => string '57' (length=2)
2 => ...
Note: If the image is added with remote url, the attachment id will always be null.
- To get featured images of specific post
if( function_exists('dfiGetFeaturedImages') )
$featuredImages = dfiGetFeaturedImages($postId);
- To get featured images in a post loop.
<?php
while ( have_posts() ) : the_post();
if( function_exists('dfiGetFeaturedImages') ) {
$featuredImages = dfiGetFeaturedImages();
}
endwhile;
?>
- The data is returned as an array that contain selected image and full size url of the selected image.
array
0 =>
array
'thumb' => string 'http://your_site/upload_path/yourSelectedImage.jpg' (length=50)
'full' => string 'http://your_site/upload_path/yourSelectedImage_fullSize.jpg' (length=69)
1 =>
array
'thumb' => string 'http://your_site/upload_path/yourSelectedImage.jpg' (length=50)
'full' => string 'http://your_site/upload_path/yourSelectedImage_fullSize.jpg' (length=69)
2 => ...