WordPress.org

Support

Support » How-To and Troubleshooting » PHP Get Theme Folder

PHP Get Theme Folder

  • Jellyfire
    Member

    @jellyfire

    Hey, I am new to wordpress and php, although I have experience in a C++ language (MEL). But am having problems trying to get on my feet with a few things.

    I’m creating a theme from scratch for my website. The theme directory has an images folder as well as the css and php files. The small problem I have is when the php files are brought together that html file is at “site.com/wordpress/page.html” so any images in the image folder won’t work being relative to the index.php file.

    What is the code to get my images to have a prefix to the theme directory?
    I tried this after doing a search on here but it didn’t work:
    <a href="#"><img src="<?php TEMPLATEPATH(); ?>/images/resume.gif" /></a>

    What am I doing wrong?
    Thanks for any help.
    Christian

Viewing 4 replies - 1 through 4 (of 4 total)
  • <?php include(TEMPLATEPATH . ‘/images/resume.gif’; ?>

    Jellyfire
    Member

    @jellyfire

    Thanks, although I’m getting a problem that I think is bigger than I originally though (that I just didn’t know the syntax).

    If I hard-code it, my site shows up fine:
    <a href="#"><img src="/images/resume.gif'" /></a>

    If I do this:
    <a href="#"><img src="<?php include(TEMPLATEPATH . '/images/resume.gif'; ?>" /></a>

    Then my entire site dissapears and just shows white and the source is blank.
    Am I being completley stupid?
    Christian

    Sorry my fault, its trying to include if you do that – although note you didnt have right closing bracket.

    Try this

    src=”<?php bloginfo(‘stylesheet_directory’); ?>/images/resume.gif”

    Jellyfire
    Member

    @jellyfire

    Brilliant! That works perfectly.
    Thanks for your help!
    Christian

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP Get Theme Folder’ is closed to new replies.