help with PHP (getting thumbnail into related posts widget)
-
Hi all,
my theme uses the custom field “Thumbnail”, which contains the url of a little thumbnail image for each post. Now I am trying to style the YARPP Related Posts Widget Template to display those thumbnails as well. I actually think it should be easy if I just know some PHP. (unfortunately I don’t).
The theme code that creates the thumbnail looks like this:
<img src="<?php $nothumb = get_bloginfo('template_directory'); $thumb = get_post_meta($post->ID, "Thumbnail", true); if ($thumb == NULL) { echo ''.$nothumb.'/images/defaultthumb.jpg'; } else { echo $thumb; } ?>" height="85" width="65" class="a-left-img" /></div>
Now the YARPP Template: It works fine except for the image, because I can’t get the thumbnail url in there. I get errors whenever I try to add something (or nothing happens at all). I have a URL for every post, so I don’t really need the “nothumb” stuff from above.
The code looks like this:
<?php if (have_posts()) { $output .= '<div class="singlesidebar">'; while (have_posts()) { the_post(); $output .= '<div class="related"><img src="" height="85" width="65" /><h2"><a href="'.get_permalink().'">'.get_the_title().'</a></h2><p>'.get_the_time('d.m.Y').'</p></div>'; } $output .= '</div>'; }
Now dear PHP-buffs, what should I add to get the image url?
- The topic ‘help with PHP (getting thumbnail into related posts widget)’ is closed to new replies.