From a8a94eef46fb48f444ade1316eb9a9f86c86dac6 Mon Sep 17 00:00:00 2001 From: "Philip M. Hofer (Frumph)" Date: Wed, 30 Dec 2009 03:57:23 -0800 Subject: [PATCH] Better Query for LatestThumbnailWidget.inc Signed-off-by: Philip M. Hofer (Frumph) --- widgets/LatestThumbnailWidget.inc | 45 ++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/widgets/LatestThumbnailWidget.inc b/widgets/LatestThumbnailWidget.inc index 57f44e9..77aee92 100644 --- a/widgets/LatestThumbnailWidget.inc +++ b/widgets/LatestThumbnailWidget.inc @@ -26,24 +26,37 @@ class ComicPressLatestThumbnailWidget extends WP_Widget { echo $before_widget; $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }; - $latestcomics = get_posts('numberposts=1&category='.get_all_comic_categories_as_cat_string()); + Protect(); + $comic_query = 'showposts=1&cat='.get_all_comic_categories_as_cat_string(); + query_posts($comic_query); $archive_image = null; - - foreach($latestcomics as $post) : - foreach (array("archive", "rss", "mini", "comic") as $type) { - if (($requested_archive_image = get_comic_url($type, $post)) !== false) { - $archive_image = "\"".get_the_title()."\""; - break; + if (have_posts()) { + while (have_posts()) : the_post(); + if (!empty($post->post_content)) { + echo $before_widget; + $temp_query = $wp_query->is_single; + $wp_query->is_single = true; + foreach (array("archive", "rss", "mini", "comic") as $type) { + if (($requested_archive_image = get_comic_url($type, $post)) !== false) { + $archive_image = "\"".get_the_title()."\""; + break; + } + } + if (function_exists('has_post_thumbnail')) { + if ( has_post_thumbnail($post->ID) ) { + $archive_image = get_the_post_thumbnail($post->ID,'full'); + } + } ?> + + is_single = $temp_query; + echo $after_widget; } - } - if (function_exists('has_post_thumbnail')) { - if ( has_post_thumbnail($post->ID) ) { - $archive_image = get_the_post_thumbnail($post->ID,'full'); - } - } - ?> - -