1

I believe the answer o this question was posted on this page, but it is still not clear to me. The snippets are scattered all over the discussion and several glitches happen when I implement them.

3
  • 1
    What code have you tried? What's not working about it? Oct 25, 2013 at 18:07
  • I tried the code snippets suggested on the link I posted, but it seems like a combination of the answers posted there is the correct answer. I have not found the right combination. Oct 25, 2013 at 18:11
  • Please edit your question to include what you're currently trying, as well as what's not working as expected. Otherwise, we have no way to help answer the question. Oct 25, 2013 at 18:22

1 Answer 1

0

I was looking for a code snippet that will extract the URL of a post thumbnail to be used as a background image. Through research elsewhere, the best answer I found is the code snippet below:

<div style="background: url(<?php $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id,'large', true); echo $image_url[0]; ?>)"></div>

This code sets the large thumbnail of a post as the background image in this div tag. From here I believe you should be able to modify this code to your particular situation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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