WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I hope someone will be able to help me with this, because it's starting to freak me out.

Have been searching hours to find a way to put image paths in my stylesheet, but have not been able to. The path must not be absolute or "theme dependant". The only way I have been able to fix my issue, is to do add the following within my html file:

<style type="text/css">
    #menu .menu-drop .menu-label {
        background: url(<?php echo get_template_directory_uri()."/admin/images/drop1.png"; ?>) no-repeat right;
    #menu li:hover .menu-drop .menu-label {
        background: url(<?php echo get_template_directory_uri()."/admin/images/drop2.png"; ?>) no-repeat right;
    #menu .menu-sub li:hover {
        background: #2a2a2a url(<?php echo get_template_directory_uri()."/admin/images/select.png"; ?>) no-repeat 10px;

As you can see, I simply add the background image "manually" in the html file after including the stylesheet in the header.

Any idea how to transfer the above to a stylesheet, or is that not possible?

share|improve this question
1. Blow no. 1 — The path must not be absolute or "theme dependant" 2. Blow no. 2 — transfer the above [CSS] to a stylesheet — The way it is, you simply CAN'T. Or you will have to frame your question more clearly. You are confused, and so am I, after reading it. :) – its_me Jul 7 '12 at 8:22
up vote 0 down vote accepted

Use a relative path in your stylesheet. If the CSS file is in /style.css:

#menu .menu-drop .menu-label {
    background: url(admin/images/drop1.png) no-repeat right;
share|improve this answer
can't get relative path to work either. Guess I have to insert it manually in the admin.php page instead of my stylesheet :( – Kenneth Poulsen Jul 7 '12 at 12:18
Explain why you cannot use relative paths. – toscho Jul 7 '12 at 12:29
The css file is placed in a CSS folder, this worked though: background: url("../images/drop1.png") no-repeat right; Your solution worked though, thanks ;) – Kenneth Poulsen Jul 7 '12 at 18:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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