Better Query for LatestThumbnailWidget.inc
Signed-off-by: Philip M. Hofer (Frumph) <frumph_dragon@yahoo.com>
This commit is contained in:
parent
eb6db19306
commit
a8a94eef46
|
@ -26,10 +26,16 @@ class ComicPressLatestThumbnailWidget extends WP_Widget {
|
||||||
echo $before_widget;
|
echo $before_widget;
|
||||||
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
|
$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
|
||||||
if ( !empty( $title ) ) { echo $before_title . $title . $after_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;
|
$archive_image = null;
|
||||||
|
if (have_posts()) {
|
||||||
foreach($latestcomics as $post) :
|
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) {
|
foreach (array("archive", "rss", "mini", "comic") as $type) {
|
||||||
if (($requested_archive_image = get_comic_url($type, $post)) !== false) {
|
if (($requested_archive_image = get_comic_url($type, $post)) !== false) {
|
||||||
$archive_image = "<img src=\"$requested_archive_image\" alt=\"".get_the_title()."\" title=\"".get_the_title()."\" />";
|
$archive_image = "<img src=\"$requested_archive_image\" alt=\"".get_the_title()."\" title=\"".get_the_title()."\" />";
|
||||||
|
@ -40,10 +46,17 @@ class ComicPressLatestThumbnailWidget extends WP_Widget {
|
||||||
if ( has_post_thumbnail($post->ID) ) {
|
if ( has_post_thumbnail($post->ID) ) {
|
||||||
$archive_image = get_the_post_thumbnail($post->ID,'full');
|
$archive_image = get_the_post_thumbnail($post->ID,'full');
|
||||||
}
|
}
|
||||||
}
|
} ?>
|
||||||
?>
|
|
||||||
<a href="<?php the_permalink(); ?>"><?php echo $archive_image; ?></a>
|
<a href="<?php the_permalink(); ?>"><?php echo $archive_image; ?></a>
|
||||||
<?php endforeach;
|
<?php
|
||||||
|
$wp_query->is_single = $temp_query;
|
||||||
|
echo $after_widget;
|
||||||
|
}
|
||||||
|
endwhile;
|
||||||
|
}
|
||||||
|
Restore();
|
||||||
|
UnProtect();
|
||||||
|
wp_reset_query();
|
||||||
echo $after_widget;
|
echo $after_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue