WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] trying to add a static image (6 posts)

  1. Aaron Happe
    Member
    Posted 1 year ago #

    Hello.

    I am trying to add a static image into my twentytwelve theme. I am having trouble getting this to work.

    The code I am using is:
    <img src="<?php bloginfo('template_url'); ?>/images/brandingImages_03.png">

    The image file is within my child theme folder, under a folder called images.

    Any suggestions?

  2. Andrei Olsen
    Member
    Posted 1 year ago #

    Use get_stylesheet_directory_uri instead.
    <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/brandingImages_03.png">

    bloginfo returns parent's URI.

  3. Aaron Happe
    Member
    Posted 1 year ago #

    Thank you! that worked.

  4. Aaron Happe
    Member
    Posted 1 year ago #

    BTW, so are you saying the code I entered first would return the URI for the images directory outside of the theme? Or what? In other words, if I was to use the code I used above, what directory would my image have to be in, in order for it to work?

  5. Andrei Olsen
    Member
    Posted 1 year ago #

    Like I said, bloginfo('template_url') will return you your parent's theme URI. In your case it will be http://<your site>/wp-content/themes/twentytwelve.

    Since you created a child theme and your images are there, you want to get a child theme's URI. That's why you should use get_stylesheet_directory_uri.

  6. Aaron Happe
    Member
    Posted 1 year ago #

    I get you now. Thanks for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic