How can I show the post thumbnail from the most recent of a certain post type, in widget?

Moving here so comments don’t turn into a mess.

Basically there are two things that can go wrong here:

  1. Fetching of posts. Check that $thumbnails gets correct post and only one. I am not sure if that is the issue, but get_posts() docs list numberposts argument instead of posts_per_page that is listed for query_posts(). That might make a difference.

  2. Messing with global variables. For this usage I wouldn’t touch global $post at all, directly or with setup_postdata() either. Just use non-loop versions of functions that can fetch things you need by post id – get_permalink() and get_the_post_thumbnail().

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)