WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] How to make an image background of a page with php

[Resolved] How to make an image background of a page with php

  • 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

Viewing 1 replies (of 1 total)
  • 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 ;">

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] How to make an image background of a page with php’ is closed to new replies.