ThemeShaper Forums » Thematic

[closed]

Image URLs in Child themes

(6 posts)
  • Started 4 years ago by pyemachine
  • Latest reply from pyemachine
  • This topic is resolved
  1. pyemachine
    Member

    I am having a great time creating a Child theme to my thematic Wordpress site. I am learning a lot quickly. One thing I can't seem to find out about though is how to do image URLs correctly in my functions.

    Currently I am working on a site locally and when I create a function to add some graphic elements to the sidebar / header / footer I have to do a complete path like so
    http://localhost:8888/MySitefolder/wp-content/themes/MySite/images/issy_hero.png
    I cannot seem to use the wordpress code <?php bloginfo('template_url'); ?>

    This means when I finally go live with the site i will have to change those URLS to the new host.

    Any help on best practices here would be greatly appreciated.

    Cheers
    Pyemachine

    Posted 4 years ago #
  2. Hi pyemachine,

    I think the issue here is that bloginfo() is going to echo the output and that wont work inside some of Thematic's core functions. Try get_bloginfo() instead and see if that works for you.

    http://codex.wordpress.org/Template_Tags/get_bloginfo

    -Gene

    Posted 4 years ago #
  3. pyemachine
    Member

    mmm i had a look at bloginfo() and it confirms that the URL for the site is directed to the thematic folder. not sure what i can do to change that outcome. so full paths look like the solution. bummer.

    Posted 4 years ago #
  4. OK I think I get what we're trying to do... try:

    bloginfo('stylesheet_url')

    the template url will take you to the parent theme directory while the stylesheet url will take you to the child theme directory

    Posted 4 years ago #
  5. <img src="<?php echo bloginfo('stylesheet_directory')?>/images/file.png"/>

    is what I use to display images that I have stored in my theme's images folder.

    Posted 4 years ago #
  6. pyemachine
    Member

    Thanks helgatheviking and em hr. My image URLs are working a treat now with <?php echo bloginfo('stylesheet_directory')?>

    cheers

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.