Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].
Hi!
I’m working on a custom SO widget that would allow to manipulate the post thumbnail.
 When using the “preview” button, nothing shows up.
Here is the code inside the widget template:
if($instance['image']['featured_image'] ){
	the_post_thumbnail();
}
I’m going to try using get_template_variables( $instance, $args ) but is there any built-in method?
Thank you!
 A.
That’s a very good suggestion! If you have a moment, could you make this suggestion over on our Github issue tracker. As a developer yourself, it would be useful for you to post technical bug reports and feature suggestions there.
https://github.com/siteorigin/so-widgets-bundle/issues
Actually it was quite easy to make it work, using get_template_variables(). Here is how I did it:
In the main widget declaration file:
function get_template_variables( $instance, $args ) { if( empty( $instance ) ) return array(); return array( 'queried_object' => get_queried_object(), 'featured_image'=>$instance['image']['featured_image'], 'image_file'=>$instance['image']['image_file'], 'title'=>$instance['title'], ); }and in the template file:
setup_postdata($queried_object); ?><figure><? the_post_thumbnail('large');?></figure> // More code .. // Don't forget to release the $post wp_reset_postdata();