List category posts - Version 0.7.2

Version Description

Template system has changed. Now the posts loop must be defined inside the template. Check templates/default.php for an example.

=

Download this release

Release Info

Developer fernandobt
Plugin Icon 128x128 List category posts
Version 0.7.2
Comparing to
See all releases

Code changes from version 0.7.1 to 0.7.2

Files changed (3) hide show
  1. list_cat_posts.php +23 -23
  2. readme.txt +11 -1
  3. templates/default.php +11 -2
list_cat_posts.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: List category posts
4
  Plugin URI: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
5
  Description: List Category Posts allows you to list posts from a category into a post/page using the [catlist] shortcode. This shortcode accepts a category name or id, the order in which you want the posts to display, and the number of posts to display. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2].
6
- Version: 0.7.1
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/wordpress/
9
  */
@@ -25,6 +25,11 @@ along with this program; if not, write to the Free Software
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
 
 
 
 
 
 
28
  //Shortcode [catlist parameter="value"]
29
  function catlist_func($atts, $content=null) {
30
  $atts=shortcode_atts(array(
@@ -55,13 +60,14 @@ function list_category_posts($atts){
55
  $category = 'cat=' . $atts['id'];
56
  $category_id = $atts['id'];
57
  }
58
-
59
  //Link to the category:
60
- if ($atts['catname'] == 'yes'){
 
61
  $cat_link = get_category_link($category_id);
62
  $cat_data = get_category($atts['id']);
63
- $cat_title = $catdata->name;
64
- $cat_link_string = '<a href=' . $cat_link . ' title="' . $cat_title . '">' . $cat_name . '<a/>';
65
  }
66
  //Build the query for get_posts()
67
  $catposts = get_posts($category.'&numberposts=' . $atts['numberposts'] .
@@ -70,18 +76,17 @@ function list_category_posts($atts){
70
  '&exclude=' . $atts['excludeposts'] .
71
  '&offset=' . $atts['offset'] );
72
  //Template code:
73
- $tplFileName= $atts['template'] != 'default'?dirname(__FILE__).'/templates/'.$atts['template'].'.php' : null;
74
  if ((!empty($tplFileName)) && (is_readable($tplFileName))) {
75
- $lcpTemplate = true;
76
  }else{
77
- $output = '<ul class="lcp_catlist">';//For default ul
78
- }
79
-
80
- foreach($catposts as $single):
81
- //Template idea by Verex
82
- if($lcpTemplate){
83
- require($tplFileName);
84
- } else {
85
  $output .= '<li><a href="' . get_permalink($single->ID).'">' . $single->post_title . '</a>';
86
  if($atts['date']=='yes'){
87
  $output .= ' - ' . get_the_time($atts['dateformat'], $single);//by Verex, great idea!
@@ -97,9 +102,9 @@ function list_category_posts($atts){
97
  $output .= "<p>$single->post_excerpt</p>";
98
  }
99
  $output.="</li>";
100
- }
101
- endforeach;
102
- if(!$lcpTemplate): $output .= "</ul>"; endif;
103
  return $output;
104
  }
105
 
@@ -107,9 +112,4 @@ function lcp_add_option_page(){
107
  add_options_page('List Category Posts', 'List Category Posts', 'manage_options','list-category-posts/list_cat_posts_options.php');
108
  }
109
 
110
- //Sidebar Widget:
111
- include('list_cat_posts_widget.php');
112
- //Filters and actions:
113
- add_action('plugins_loaded', 'lcp_load_widget');
114
-
115
  ?>
3
  Plugin Name: List category posts
4
  Plugin URI: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
5
  Description: List Category Posts allows you to list posts from a category into a post/page using the [catlist] shortcode. This shortcode accepts a category name or id, the order in which you want the posts to display, and the number of posts to display. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2].
6
+ Version: 0.7.2
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/wordpress/
9
  */
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
 
28
+ //Sidebar Widget:
29
+ include('list_cat_posts_widget.php');
30
+ //Filters and actions:
31
+ add_action('plugins_loaded', 'lcp_load_widget');
32
+
33
  //Shortcode [catlist parameter="value"]
34
  function catlist_func($atts, $content=null) {
35
  $atts=shortcode_atts(array(
60
  $category = 'cat=' . $atts['id'];
61
  $category_id = $atts['id'];
62
  }
63
+
64
  //Link to the category:
65
+ $cat_link_string = '';
66
+ if ($atts['catlink'] == 'yes'){
67
  $cat_link = get_category_link($category_id);
68
  $cat_data = get_category($atts['id']);
69
+ $cat_title = $cat_data->name;
70
+ $cat_link_string = '<a href=' . $cat_link . ' title="' . $cat_title . '">' . $cat_title . '<a/>';
71
  }
72
  //Build the query for get_posts()
73
  $catposts = get_posts($category.'&numberposts=' . $atts['numberposts'] .
76
  '&exclude=' . $atts['excludeposts'] .
77
  '&offset=' . $atts['offset'] );
78
  //Template code:
79
+ $tplFileName = $atts['template'] != 'default'?dirname(__FILE__).'/templates/'.$atts['template'].'.php' : null;
80
  if ((!empty($tplFileName)) && (is_readable($tplFileName))) {
81
+ require($tplFileName);
82
  }else{
83
+ if ($cat_link_string != ''){
84
+ $output = '<p><strong>' . $cat_link_string . '</strong></p>';
85
+ }else{
86
+ $output = '';
87
+ }
88
+ $output .= '<ul class="lcp_catlist">';//For default ul
89
+ foreach($catposts as $single):
 
90
  $output .= '<li><a href="' . get_permalink($single->ID).'">' . $single->post_title . '</a>';
91
  if($atts['date']=='yes'){
92
  $output .= ' - ' . get_the_time($atts['dateformat'], $single);//by Verex, great idea!
102
  $output .= "<p>$single->post_excerpt</p>";
103
  }
104
  $output.="</li>";
105
+ endforeach;
106
+ $output .= "</ul>";
107
+ }
108
  return $output;
109
  }
110
 
112
  add_options_page('List Category Posts', 'List Category Posts', 'manage_options','list-category-posts/list_cat_posts_options.php');
113
  }
114
 
 
 
 
 
 
115
  ?>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate Link: http://picandocodigo.net/programacion/wordpress/list-category-posts
4
  Tags: list, categories, posts, cms
5
  Requires at least: 2.6
6
  Tested up to: 2.9
7
- Stable tag: 0.7.1
8
 
9
  == Description ==
10
  List Category Posts is a simple WordPress plugin which allows you to list posts from a category into a post/page using the [catlist] shortcode. This shortcode accepts a category name or id, the order in which you want the posts to display, and the number of posts to display. You can use [catlist] as many times as needed with different arguments. Great to use WordPress as a CMS, and create pages with several categories posts.
@@ -80,8 +80,18 @@ Your comments and feedback are welcome at: http://picandocodigo.net/programacion
80
  * **Support forum** on the following URL: http://foro.picandocodigo.net/viewtopic.php?f=27&t=221
81
  * **New feature requests** on the following URL: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
82
 
 
 
 
 
 
 
83
  == Changelog ==
84
 
 
 
 
 
85
  = 0.7.1 =
86
  * Fixed uber stupid bug with offset... Sorry about that!
87
 
4
  Tags: list, categories, posts, cms
5
  Requires at least: 2.6
6
  Tested up to: 2.9
7
+ Stable tag: 0.7.2
8
 
9
  == Description ==
10
  List Category Posts is a simple WordPress plugin which allows you to list posts from a category into a post/page using the [catlist] shortcode. This shortcode accepts a category name or id, the order in which you want the posts to display, and the number of posts to display. You can use [catlist] as many times as needed with different arguments. Great to use WordPress as a CMS, and create pages with several categories posts.
80
  * **Support forum** on the following URL: http://foro.picandocodigo.net/viewtopic.php?f=27&t=221
81
  * **New feature requests** on the following URL: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
82
 
83
+ == Upgrade Notice ==
84
+
85
+ = 0.7.2 =
86
+ Template system has changed. Now the posts loop must be defined inside the template. Check templates/default.php for an example.
87
+
88
+
89
  == Changelog ==
90
 
91
+ = 0.7.2 =
92
+ * Fixed link to category.
93
+ * Improved template system.
94
+
95
  = 0.7.1 =
96
  * Fixed uber stupid bug with offset... Sorry about that!
97
 
templates/default.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: List Category Posts - Template
4
  Plugin URI: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
5
  Description: Template file for List Category Post Plugin for Wordpress which is used by plugin by argument template=value.php
6
- Version: 0.0.3
7
  Author: Radek Uldrych & Fernando Briano
8
  Author URI: http://picandocodigo.net http://radoviny.net
9
  */
@@ -24,7 +24,15 @@ You should have received a copy of the GNU General Public License
24
  along with this program; if not, write to the Free Software
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
- $output .= '<p><strong>' . $cat_link_string . '</strong></p>';
 
 
 
 
 
 
 
 
28
  $output .= '<li><a href="' . get_permalink($single->ID) . '">' . $single->post_title . '</a>';
29
  //Style for date:
30
  if($atts['date']=='yes'){
@@ -44,4 +52,5 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
44
  $output .= '<p>' . $single->post_excerpt . '</p>';
45
  }
46
  $output.='</li>';
 
47
  ?>
3
  Plugin Name: List Category Posts - Template
4
  Plugin URI: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
5
  Description: Template file for List Category Post Plugin for Wordpress which is used by plugin by argument template=value.php
6
+ Version: 0.4
7
  Author: Radek Uldrych & Fernando Briano
8
  Author URI: http://picandocodigo.net http://radoviny.net
9
  */
24
  along with this program; if not, write to the Free Software
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
+
28
+ //Show category?
29
+ if ($cat_link_string != ''){
30
+ $output = '<p><strong>' . $cat_link_string . '</strong></p>';
31
+ }else{
32
+ $output = '';
33
+ }
34
+ //Posts loop:
35
+ foreach($catposts as $single):
36
  $output .= '<li><a href="' . get_permalink($single->ID) . '">' . $single->post_title . '</a>';
37
  //Style for date:
38
  if($atts['date']=='yes'){
52
  $output .= '<p>' . $single->post_excerpt . '</p>';
53
  }
54
  $output.='</li>';
55
+ endforeach;
56
  ?>