5

I'm trying to develop a WP theme for a client via localhost. I'm using XAMPP on Windows 8 and has set up vhosts to something like myclient.dev. This works for stylesheet

<?= get_stylesheet_uri(); ?>

But when trying to use get_stylesheet_directory() (Mainly for images) I get the wrong path: So

<img  class="logo" src="<?= get_stylesheet_directory(); ?>//images/logo.png">

The src returns:

http://myclient.dev/C:/Users/..../Localhost/hfclients.dev/myclient.dev/wp-content/themes/myclient.dev/images/cta-banner.jpg

How can I fix this?

  • 1
    You seem to be mixing up get_stylesheet_directory() and get_stylesheet_uri() (and probably get_stylesheet_directory_uri()) in your question. Please check what exactly your code has. – Rarst Jul 7 '13 at 23:19
  • @Rarst, oops, yeah, fixed the question. – devs Jul 7 '13 at 23:50
  • @devs, use get_stylesheet_uri() even for <img />'s. get_stylesheet_directory() is the local filepath, typically for include & working with files server-side. – TheDeadMedic Jul 7 '13 at 23:54
  • 1
    Avoid PHP short tags like <?= in WordPress. That mostly doesn't work out. – kaiser Jul 8 '13 at 0:34
  • @kaiser un-related and it's supported everywhere :/ – devs Jul 8 '13 at 1:03
5

As I was getting at in comment:

Just use latter. :)

  • Thanks! Also thanks for not getting on me for using shorttags -_- – devs Jul 8 '13 at 1:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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