I'm new to WP and PHP and I'm trying to convert my 'old' HTML theme into a WP theme. I created my index.php page and linked it to the style.css. I have some images in the css and, from what I've read, I've understood that I have to change my image url so that instead of having:

background-image: url(../assets/Logo.png);

I would have

background-image: url("<?php bloginfo('template_directory'); ?>/assets/Logo.png");

So I made this change on all the urls but when the index loads, even though every CSS element is fine, the images don't appear. However, if I revert them to the html url, the CSS doesn't display at all. And finally, if I have just one bloginfo url in the css and all the others are hmtl, the html ones will load, but the php one won't.

I've changed bloginfo to get_bloginfo (as some suggested) but still no solving. I went through all the parameters related to the path (template_url, stylesheet_directory), but still no change.

I would really appreciate some suggestions or explanations.

Thanks a lot!

1 Answer 1


If your style.css is in /wp-content/themes/themedirectory, and your image is at /wp-content/themes/themedirectory/images/image.jpg, then your css will be this:

background-image: url("images/image.jpg");

You can't use php in a css file, it will not parse unless included via php (instead of with <link>).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.