Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I define the template directory (So I can reference and image in the 'images' folder) from within this php widget code?

// WIDGET CODE GOES HERE
query_posts('posts_per_page=1&post_type=testimonial&orderby=rand');
if (have_posts()) : 
echo "<div class=\"testimonial-widget group\">";
while (have_posts()) : the_post();
    the_post_thumbnail('widget-test-thumb');
    echo "<p><span class=\"left\">\"</span>";
    $excerpt = get_the_excerpt();
            // IMAGE WOULD GO HERE
    echo string_limit_words($excerpt,15);
    echo "<span class=\"right\">\"</span></p>";
    echo "<h2>".get_the_title()."</h2>";
endwhile;
echo "</div>";
endif; 
wp_reset_query();
share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

You can use get_template_directory_uri() and it will return the url up to the template directory then you can just append the '/images/FILENAME.EXT' to it to pull in the image.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.