• Resolved zed28

    (@zed28)


    Hi,

    I am using this:

    <div class=”smallblock-cont” style=”background-image: url(<?php echo get_template_directory_uri(); ?>/images/image.jpg)”>

    to display background image on my localhost site.
    But image does not display.

    Full path to images is:

    https://localhost/sitename/wp-content/themes/themename/images/image.jpg

    I do not want use full path, because I do not want overwrite all image paths when moving to webhosting.
    Relative paths “/images/image.jpg” dont work.

    Can anybody help me?

    Thanks
    Alex

Viewing 2 replies - 1 through 2 (of 2 total)
  • Remove the ‘echo‘, you are using get_template_directory_uri in a string in HTML, not printing it.

    Also, where is this code added? In a page or post or a page template? ?

    Thread Starter zed28

    (@zed28)

    Oh, my mistake. I did not know that I can not execute php code in page content.
    I must create new template file and put code there.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Background image – does not display’ is closed to new replies.