Category Posts Widget - Version 2.3

Version Description

Download this release

Release Info

Developer ZephyrWest
Plugin Icon 128x128 Category Posts Widget
Version 2.3
Comparing to
See all releases

Code changes from version 2.2 to 2.3

Files changed (2) hide show
  1. cat-posts.php +6 -12
  2. readme.txt +5 -1
cat-posts.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Category Posts Widget
4
  Plugin URI: http://jameslao.com/2009/07/29/category-posts-widget-2-0/
5
  Description: Adds a widget that can display a specified number of posts from a single category. Can also set how many widgets to show.
6
  Author: James Lao
7
- Version: 2.2
8
  Author URI: http://jameslao.com/
9
  */
10
 
@@ -27,11 +27,8 @@ function widget($args, $instance) {
27
  $instance["title"] = $category_info->name;
28
  }
29
 
30
- // Save old query...
31
- $old_query = $wp_query;
32
-
33
  // Get array of post info.
34
- query_posts("showposts=" . $instance["num"] . "&cat=" . $instance["cat"]);
35
 
36
  echo $before_widget;
37
 
@@ -47,17 +44,17 @@ function widget($args, $instance) {
47
  // Post list
48
  echo "<ul>\n";
49
 
50
- while ( have_posts() ) : the_post();
51
  ?>
52
  <li class='cat-post-item'>
53
 
54
- <?php if ( (bool) $instance["thumbnail"] && function_exists('p75HasThumbnail') && p75HasThumbnail($post->ID) ) { ?>
55
 
56
- <a href="<?php the_permalink(); ?>" title="<?php echo the_title_attribute(); ?>"><img class='alignleft' src='<?php echo p75GetThumbnail($post->ID, $instance["thumbnail_width"], $instance["thumbnail_height"]); ?>' alt='<?php echo the_title_attribute(); ?>' /></a>
57
 
58
  <?php } // end thumbnail function check ?>
59
 
60
- <a class="post-title" href="<?php echo the_permalink(); ?>" title="<?php echo the_title_attribute(); ?>"><?php echo the_title(); ?></a>
61
 
62
  <?php if ( $instance['excerpt'] ) the_excerpt(); ?>
63
  </li>
@@ -67,9 +64,6 @@ function widget($args, $instance) {
67
  echo "</ul>\n";
68
 
69
  echo $after_widget;
70
-
71
- // Won't even know I was here...
72
- $wp_query = $old_query;
73
  }
74
 
75
  /**
4
  Plugin URI: http://jameslao.com/2009/07/29/category-posts-widget-2-0/
5
  Description: Adds a widget that can display a specified number of posts from a single category. Can also set how many widgets to show.
6
  Author: James Lao
7
+ Version: 2.3
8
  Author URI: http://jameslao.com/
9
  */
10
 
27
  $instance["title"] = $category_info->name;
28
  }
29
 
 
 
 
30
  // Get array of post info.
31
+ $cat_posts = new WP_Query("showposts=" . $instance["num"] . "&cat=" . $instance["cat"]);
32
 
33
  echo $before_widget;
34
 
44
  // Post list
45
  echo "<ul>\n";
46
 
47
+ while ( $cat_posts->have_posts() ) : $cat_posts->the_post();
48
  ?>
49
  <li class='cat-post-item'>
50
 
51
+ <?php if ( (bool) $instance["thumbnail"] && function_exists('p75HasThumbnail') && p75HasThumbnail($cat_posts->post->ID) ) { ?>
52
 
53
+ <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><img class='alignleft' src='<?php echo p75GetThumbnail($post->ID, $instance["thumbnail_width"], $instance["thumbnail_height"]); ?>' alt='<?php the_title_attribute(); ?>' /></a>
54
 
55
  <?php } // end thumbnail function check ?>
56
 
57
+ <a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
58
 
59
  <?php if ( $instance['excerpt'] ) the_excerpt(); ?>
60
  </li>
64
  echo "</ul>\n";
65
 
66
  echo $after_widget;
 
 
 
67
  }
68
 
69
  /**
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://jameslao.com/
4
  Tags: category, posts, widget
5
  Requires at least: 2.8
6
  Tested up to: 2.8.2
7
- Stable tag: 2.2
8
 
9
  Adds a widget that shows the most recent posts in a single category.
10
 
@@ -30,6 +30,10 @@ Features:
30
 
31
  == Changelog ==
32
 
 
 
 
 
33
  2.1
34
 
35
  * Fixed bug where wp_query global was getting over written.
4
  Tags: category, posts, widget
5
  Requires at least: 2.8
6
  Tested up to: 2.8.2
7
+ Stable tag: 2.3
8
 
9
  Adds a widget that shows the most recent posts in a single category.
10
 
30
 
31
  == Changelog ==
32
 
33
+ 2.3
34
+
35
+ * Really tried to fix bug where wp_query global was getting over written by manually instantiating a WP_Query object
36
+
37
  2.1
38
 
39
  * Fixed bug where wp_query global was getting over written.