Я вывожу список популярных статей в сайтбаре этим кодом:
<?php
$now = gmdate("Y-m-d H:i:s",time());
$lastmonth = gmdate("Y-m-d H:i:s",gmmktime(date("H"), date("i"), date("s"), date("m")-1,date("d"),date("Y")));
$popularposts = "SELECT ID, post_title, post_date, comment_count, COUNT($wpdb->comments.comment_post_ID) AS 'popular' FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish' AND post_date < '$now' AND post_date > '$lastmonth' AND comment_status = 'open' GROUP BY $wpdb->comments.comment_post_ID ORDER BY popular DESC LIMIT 11";
$posts = $wpdb->get_results($popularposts);
$popular = '';
if($posts){
foreach($posts as $post){
$post_title = stripslashes($post->post_title);
$post_date = stripslashes($post->post_date);
$comments = stripslashes($post->comment_count);
$guid = get_permalink($post->ID);
$popular .= '<li><span class="title"><a href="'.$guid.'" title="'.$post_title.'">'.$post_title.'</a></span><br/>
<span class="meta">With <a href="'.$guid.'#commenting" title="Read the comments on '.$post_title.'">'.$comments.' comments</a> since '.$post_date.'</span></li>';
}
}echo $popular;
?>
Картинки выводятся так:
<?php $image = get_post_meta($post->ID, 'thumbnail', true); if($image !== '') { ?>
<img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" width=30 height=30 title="<?php the_title(); ?>" />
<?php } ?>
Подскажите, пожалуйста, как корректно вставить код вызова картинок в первый код?
Пыталась просто вставить его перед тегом li, выдает ошибку.
Наверное я что то не учла, но не соображу, что именно.
Может есть какие то хитрости в этом, которых я не знаю?
Помогите, плиз, разобраться.