Support » Themes and Templates » timthumb: not calling up script in TwentyEleven child theme

  • Resolved David Borrink


    I have set up timthumb in a TwentyEleven child theme. I’ve discovered that the thumbnails are not coming up in my layout because my source code tells me it’s looking for the script in TwentyEleven and not in my child theme files. Timthumb should be looking in my child theme folder.

    Here’s the code in my template, which asks for the script in the template directory in the folder “scripts”, then looks for the image in the custom field, “thumb”, of a post:

    <img src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, "thumb", $single = true); ?>&h=150&w=150&zc=1" alt="<?php the_title(); ?>" width="150" height="150"/>

    Here is the source code of the results (My URL is replaced with [MYSITE] )…

    <img src="http://[MYSITE]/wp-content/themes/twentyeleven/scripts/timthumb.php?src=http://[MYSITE]/wp-content/uploads/2012/04/10003.jpg&h=150&w=150&zc=1" alt="Fifth Test Post – 10003" width="150" height="150"/>

    You can see here that my code result is that it’s looking for the “scripts” folder in TwentyEleven. It’ll never find it. There is no “scripts” folder in TwentyEleven. I have the timthumb “scripts” folder in my child theme folder.

    So why would ‘template_directory’ bring a result of “twentyeleven” when my site is using a child theme? Is this a timthumb error?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Whenever you’re using a child theme, use stylesheet_directory instead of template_directory — stylesheet_directory refers to the stylesheet currently in use, that is, your child theme.

    Thank you, Amy!!! That was the solution. My thumbnails have appeared, and now I can really move forward on my project. This was key to getting this project to work well.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘timthumb: not calling up script in TwentyEleven child theme’ is closed to new replies.