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'm attempting to use the 'feature image' feature of Wordpress to make a full screen background, that resizes to fit the browser window using jQuery

The bit I'm stuck on is adding a custom id (#bgimg) to the code generated by this:

<div class="background"><?php the_post_thumbnail (array(1024,768));?></div>

The image generated needs to have specific id tag in it, eg...

<img id="bgimg" src="wordpress/generated/etc.jpg">

So that the jQuery plugin, can hook on to it, and scale it to fit the browser window. I know the jQuery works (as I've used it in other projects)

Any suggestions? Alex

share|improve this question
up vote 2 down vote accepted

Use get_the_post_thumbnail() instead. It allows you to pass in an array of attributes for the image tag that gets returned.

For example:

$attr = array(
    'id' => 'YOUR-UNIQUE-ID',

echo get_the_post_thumbnail( $id, 'thumbnail', $attr );


I'm dumb. the_post_thumbnail() also lets you do that. Try passing the same args array I outlined as the second param.

share|improve this answer
Thanks MathSmath, Fixed it up a treat. – Alex Dec 16 '10 at 2:08

Your Answer


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