• Resolved rioforce

    (@rioforce)


    Hi, I have an image tag in the header.php file in my WordPress child theme. I want to use the wordpress background image defined in the Admin panel as the img src.

    I found where you can call the background image from PHP, but I put it in the quotes in the src, but that will not put the image there. It leaves the img src blank when I view source in Firefox.

    https://codex.ww.wp.xz.cn/Function_Reference/get_background_image

    Basically, this is the code I wrote that did not work:

    <img id="parallaxContainer" src="<?php get_background_image(); ?>" />

    What am I doing wrong?

    Thanks for the help! 😀

Viewing 2 replies - 1 through 2 (of 2 total)
  • look closer at the example codes in your linked Codex chapter;

    you need to add echo;

    try:

    <img id="parallaxContainer" src="<?php echo get_background_image(); ?>" />

    Thread Starter rioforce

    (@rioforce)

    Ah! Thank you! I looked everywhere for a way to do that. I don’t know anything about PHP, so I guess I overlooked that echo.

    Again, Thanks! 😀

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Use get_background_image in src’ is closed to new replies.