WordPress.org

Forums

[resolved] How to make an image background of a page with php (2 posts)

  1. iversoncru
    Member
    Posted 1 year ago #

    hi!

    I have an image in $image, and i want to make it background of the page using php. Unfortunately im quite new to PHP...

    could anyone give me a hint or sth? :)

    thanks in advance for your time

  2. iversoncru
    Member
    Posted 1 year ago #

    Researching... i finally found some threats here it wordpress.org Support
    which allowed me to do it!

    Here is the code i have used, and works!

    <?php
    	$page_id = get_the_ID();
    	$page = get_page($page_id);
    ?>
    <?php $image_id = get_post_thumbnail_id(); ?>
    <?php $image_url = wp_get_attachment_image_src($image_id,'full');   ?>
    <?php $image_url[0]; ?>
    <div id="service_wrap_content" style="background:url(<?php echo $image_url[0]; ?>) no-repeat center center; height:674px ;">

Topic Closed

This topic has been closed to new replies.

About this Topic