• Resolved Grapho

    (@grapho)


    When I want to reference an image from within a template file (for instance: header.php), it seems I can only use an absolute path.

    In CSS I can use a relative path to set background images to divs and what not, but in this case I’m needing to code a few images right into a template file.

    Is there a proper way to use a relative path in a template file?

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

    (@moshu)

    Most people use the bloginfo template tag: Template_Tags/bloginfo#Parameters

    e.g. <img src="<?php bloginfo('template_directory'); ?>/images/mypic.jpg alt="" class="" />

    In that way you can move/use the theme on any server, on any WP installation, as long as the image is in the “images” folder of the theme.

    Thread Starter Grapho

    (@grapho)

    thanks so much!

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

The topic ‘SRC’ing <img> from within template file’ is closed to new replies.