How to get cropped thumbnail source for custom post type

You should add your custom image size with this code: add_image_size( ‘my-test-image-size’, 148, 148, true ); Then in your template file you can get cropped image using wp_get_attachment_image_src like this: $attachment_id = …; // i.e. get_post_thumbnail_id() $image_info = wp_get_attachment_image_src($attachment_id, ‘my-test-image-size’); echo ‘<img src=”‘. $image_info[0] .'” … />’; // $image_info[0] contains url of cropped image To … Read more

Set the background to a default image if there isn’t a specified “featured image”

I found the solution from a WordPress forum and this is what they used. Works perfect <?php if (has_post_thumbnail( $post->ID ) ): ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ” ); $image = $image[0]; ?> <?php else : $image = get_bloginfo(‘stylesheet_directory’) . ‘/lib/images/home1-1024×681.jpg’; ?> <?php endif; ?> <section id=”halfpro” style=”background-image: url(‘<?php echo $image; ?>’)” … Read more

WP dynamic featured image – Can’t get second featured image url

To get featured images of specific post/page use these below code – 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 } Please follow this link – https://github.com/ankitpokhrel/Dynamic-Featured-Image/wiki/Retrieving-data-in-a-theme

Animated Gif as Featured Image

It is perfectly fine to use animated gifs in any capacity you like in WordPress, even as featured images. When you upload an image, WordPress will process it into various shapes and sizes, as specified by your theme and possibly some plugins as well. The version of image that gets displayed is determined by your … Read more