ThemeShaper Forums » Thematic

[closed]

relative path to image file from functions.php

(3 posts)
  • Started 4 years ago by gaillen
  • Latest reply from michaelh
  • This topic is resolved
  1. gaillen
    Member

    I am using functions.php in my child theme of Thematic to add a background image. The hook works fine but only with an absolute path to the referenced image. If I try to use a relative path such as I use in my child themes CSS the image is not found.

    function full_page_background_image() { ?>
    <img src="/mandala2.jpg" alt="background image" id="full_page_bg" />
    <?php
    }
    add_action('thematic_before', 'full_page_background_image');

    Can anyone advise me on the relative path to use? my "child_theme" folder resides beside the "thematic" folder in the normal wordpress "themes" folder and I am not using a sub folder for images yet.

    Posted 4 years ago #
  2. gaillen
    Member

    Ok found the answer through trial and error. I had tried

    <?php bloginfo('template_directory'); ?>

    with no luck but I finally found a reference on WP Codex to child themes needing to be referenced through the stylesheets directory

    <?php bloginfo('stylesheet_directory'); ?>

    And yes this does work and answers my question. Here is the final code for reference sake if anyone is searching this in the future

    function full_page_background_image() { ?>
    <img src="<?php bloginfo('stylesheet_directory'); ?>/image_name.jpg" alt="background image" id="full_page_bg" />
    <?php
    }
    add_action('thematic_before', 'full_page_background_image');
    Posted 4 years ago #
  3. michaelh
    Member

    Edit: realized I put stuff in the wrong directory, please delete. :(

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.