• Resolved chezshire

    (@chezshire)


    I would like to know how to set/call the the featured image of a page as the background element. This will allow me to use one template for many pages as i can personalize them with the background image with the featured image being plugged in to the page. I’ve tried google it for an hour now and i am very lost and confused. Any help would be appreaciated.

    this is my test page: Test page. Where you see background grey, i want to call a textured image of charcoal rubbings.

    I’m a new so please be specific with me. As always any help is very very very appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Interestingly, your site does not appear to be a wordpress site anymore…

    Any thoughts?

    https://www.ads-software.com/support/topic/registration-form-error-register-link-no-workie?replies=3

    Have you tried to contact: https://www.ads-software.com/support/profile/ipstenu-dh
    ? : DreamHost WP Support Specialist

    Thread Starter chezshire

    (@chezshire)

    It’s still a wordpress – i’m not sure what you mean by ‘it doesn’t appear to be a wordpress site anymore’.

    assuming that you are familiar with setting a background image in an inline style for those elements, here is the WordPress specific part of getting the featured image url to use in the background-image url

    https://www.ads-software.com/support/topic/getting-post-thumbnail-url?replies=12

    if you are not familiar with the CSS, please ask at a dedicated CSS forum like https://csscreator.com/forum

    Thread Starter chezshire

    (@chezshire)

    Thank you Alchymyth, I found a thread where you had given some guidance on a similar subject which has got me part of the way. I’m very new to WordPress and the web and stuff like that and for my first project I bit off a lot so as to learn as much as I can. Thank you for your reference, I will go try that. And again thank you to SWD for the notes on being compromised.

    So much to learn, so overwhelming yet exciting! I’ll never be bored again.
    -m

    Thread Starter chezshire

    (@chezshire)

    Hello Alchymuyth,
    I attempted this which for i think fetched the image i wanted, but filled my background image with a translucent image fill or something that was weird, but definately not what i wanted. the below code produces a rendered result of produces a rendered html result of <div class=”jumbotron masthead” style=”background: url() !important;”>:

    <?php global $post; ?>
    <?php
    $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' );
    ?>
    <div class="jumbotron masthead" style="background: url(<?php echo $thumb_src[0];?>) !important;">

    Then I tried the code below which again produces a rendered html result of <div class=”jumbotron masthead” style=”background: url() !important;”>:

    <div class="jumbotron masthead" style="background: url(<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail_size' );
    $url = $thumb['0']; ?>) !important;">

    I then tried this bit of code which worked in a very spiffy special way that made me tingly all over (that might be the caffine and exhaustion talking, but i tingled non-the-less;
    <div class=”jumbotron masthead” style=”background-image:url(<?=$url?>);” href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?> !important;”>

    Thank you very very much. Spiffiness has occurred ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Use Featured Image as a background image for a div element on a static page’ is closed to new replies.