Support » Fixing WordPress » bloginfo(‘template_directory’); only works in header.php

  • Resolved Orabidoo


    Hi everyone,

    I’m using <?php bloginfo(‘template_directory’); ?> to link to images in my theme folder. It works in header.php, the logo is there and all is well…but in index.php the same code snippet doesn’t return anything at all.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Nile Flores


    Yoast Support

    Are you using this when you are publishing posts? It will not work there.

    It should work in your theme files only. Otherwise you will have to use the full link to images for your pages and widgets.

    But it’s working in header.php, which becomes part of index.php…right?

    I guess I could use “wp-content/themes/theme_name/images” instead, since I know the name of the theme folder (I’m making this for a company, so no one else will use it).

    Something weird is going on. I uploaded the file again and now everything works! Maybe I uploaded the file to the wrong directory by accident? I dunno.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘bloginfo(‘template_directory’); only works in header.php’ is closed to new replies.