WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've made a custom widget which shows thumbs of my latest videos. These thumbs are set to be 300px wide, which is the same width of my sidebar.

My problem is that i also want to be able to use it in my footer where the width of widgets are only 220px wide.

So basically what i want to do is: if the widget is shown in the sidebar use <?php the_post_thumbnail('media-thumb-sidebar'); ?>and if the widget is used in the footer use <?php the_post_thumbnail('media-thumb-footer'); ?>

Anyone know how i could do this? Thanks :)

share|improve this question
Why not just use css to control the size of the thumbnails and the div ? You can have different styles on the widget for example; #sidebar .widget{width:300px;} #footer .widget{width:220px;} and obviously add styles to the img tag – Xavier Apr 7 '11 at 22:49
Well i'm using the built in WP function "featured image" to show the thumbs, so wouldn't i have to make some kind of if statement to change the size of the thumb depending on if it's in footer or sidebar? – user4380 Apr 7 '11 at 22:56
up vote 1 down vote accepted

you can always get the thumbnail, but size it with CSS as Xavier mentioned.

share|improve this answer
I don't know what i was thinking, but you guys are right that works well. Thanks to you both – user4380 Apr 7 '11 at 23:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.