ThemeShaper Forums » Thematic


Adding an Image Using belowheader() Hook

(5 posts)
  • Started 11 years ago by davecrow
  • Latest reply from tarpontech
  • This topic is resolved
  1. davecrow

    I'm trying to add an image as a secondary header just below the navigation using the belowheader() hook. I've added the html and I can get text to show up, but when I place an image in the div, it doesn't show up.

    This is my first time using Thematic and the first custom function I've written, so there's probably something very simple that I'm doing wrong. Here's the code I'm trying to use:

    // Adds secondary header image
    function secondary_header() { ?>
    	<div class="secondary-header">
    		<img src="images/main-image-01.jpg">
    <?php }
    Posted 11 years ago #
  2. davecrow

    Found the issue.

    I changed the path to the image to "wp-content/themes/name-of-child-theme/images/main-image-01.jpg"

    I didn't realize the paths in the functions file weren't relative to the child theme folder. So as I guessed was something very simple I was doing wrong.

    Posted 11 years ago #
  3. Just wondering if this is the correct and/or optimal way to add a linked image above the header? Would it be better to do it via "php include" so that I don't need to edit the functions file to change the image? If so, any tips on using "php include" to add a linked image above header? Grateful for all the help I've found here - thanks all!

    Here's the function:

    //add banner_ad

    function childtheme_banner_ad() { ?>
    <div class="above-header">
    <img src="<?php echo bloginfo('stylesheet_directory') ?>/images/top-banner.png" width="960" height="96" alt="Sample banner ad" />
    <?php }
    add_action('thematic_aboveheader', 'childtheme_banner_ad');

    This works on my messy "sandbox" area:

    Posted 11 years ago #
  4. I think you're right :)

    Posted 11 years ago #
  5. my 2 cents would be to create a themes-option page so that you can easily change images using theme options. The free themes-option template and tutorial that Ian and the Automattic team posted on the themeshaper main site made it VERY EASY to create theme options.

    I'm no PHP programmer, and I figured it out in a couple hours, it was a huge cut-n-paste bonanza, now my themes are filled with options, mostly to change text and images, but it makes things soo much easier to manage.

    Posted 11 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.