List category posts - Version 0.14

Version Description

  • Added "post_type" and "post_parent" from the underlining "get_posts()" API to be usable within the short-code. By Martin Crawford, thanks!
  • Added the "class" parameter to style the default ul. You can pass a class name, or the plugin will use "lcp_catlist" bby default. Thanks Chocolaterebel (http://wordpress.org/support/topic/plugin-list-category-posts-sharing-my-own-template-in-lcp).
  • Fixed "tags" parameter on the documentation, it used to say "tag", and the plugin looks for "tags".
Download this release

Release Info

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

Code changes from version 0.13.1 to 0.14

Files changed (3) hide show
  1. list_cat_posts.php +19 -18
  2. readme.txt +26 -10
  3. templates/default.php +4 -0
list_cat_posts.php CHANGED
@@ -3,12 +3,12 @@
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.13.1
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/
9
  */
10
 
11
- /* Copyright 2008-2010 Fernando Briano (email : fernando@picandocodigo.net)
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License as published by
@@ -53,7 +53,10 @@ function catlist_func($atts, $content = null) {
53
  'content' => 'no',
54
  'catlink' => 'no',
55
  'comments' => 'no',
56
- 'thumbnail' => 'no'
 
 
 
57
  ), $atts);
58
  return list_category_posts($atts);
59
  }
@@ -86,12 +89,7 @@ function list_category_posts($atts){
86
  if ((!empty($tplFileName)) && (is_readable($tplFileName))) {
87
  require($tplFileName);
88
  }else{
89
- if ($cat_link_string != ''){
90
- $lcp_output = '<p><strong>' . $cat_link_string . '</strong></p>';
91
- } else {
92
- $lcp_output = '';
93
- }
94
- $lcp_output .= '<ul class="lcp_catlist">';//For default ul
95
  foreach ($catposts as $single):
96
  $lcp_output .= lcp_display_post($single, $atts);
97
  endforeach;
@@ -123,13 +121,16 @@ function lcp_category($lcp_category_id, $lcp_category_name, $atts){
123
  $cat_link_string = '<a href="' . $cat_link . '" title="' . $cat_title . '">' . $cat_title . '</a>';
124
  }
125
  //Build the query for get_posts()
126
- $catposts = get_posts($lcp_category.'&numberposts=' . $atts['numberposts'] .
127
  '&orderby=' . $atts['orderby'] .
128
  '&order=' . $atts['order'] .
129
  '&exclude=' . $atts['excludeposts'] .
130
  '&tag=' . $atts['tags'] .
131
- '&offset=' . $atts['offset'] );
132
- return $catposts;
 
 
 
133
  }
134
 
135
  function lcp_display_post($single, $atts){
@@ -151,8 +152,8 @@ function lcp_display_post($single, $atts){
151
  if ($atts['excerpt']!='no' && !($atts['content']=='yes' && $single->post_content) ){
152
  $lcp_output .= lcp_excerpt($single);
153
  }
154
- if ($atts['thumbnails']=='yes'){
155
- $lcp_output .= lcp_thumbnails($single);
156
  }
157
  $lcp_output.="</li>";
158
  return $lcp_output;
@@ -194,12 +195,12 @@ function lcp_excerpt($single){
194
  }
195
 
196
 
197
- function lcp_thumbnails($single){
198
- $lcp_thumbnails = '';
199
  if ( has_post_thumbnail($single->ID) ) {
200
- $lcp_thumbnails = get_the_post_thumbnail($single->ID);
201
  }
202
- return $lcp_thumbnails;
203
  }
204
 
205
  /** TODO - These are the todo's for a 1.0 release:
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.14
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/
9
  */
10
 
11
+ /* Copyright 2008-2011 Fernando Briano (email : fernando@picandocodigo.net)
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License as published by
53
  'content' => 'no',
54
  'catlink' => 'no',
55
  'comments' => 'no',
56
+ 'thumbnail' => 'no',
57
+ 'post_type' => '',
58
+ 'post_parent' => '0',
59
+ 'class' => 'lcp_catlist'
60
  ), $atts);
61
  return list_category_posts($atts);
62
  }
89
  if ((!empty($tplFileName)) && (is_readable($tplFileName))) {
90
  require($tplFileName);
91
  }else{
92
+ $lcp_output = '<ul class="'.$atts['class'].'">';//For default ul
 
 
 
 
 
93
  foreach ($catposts as $single):
94
  $lcp_output .= lcp_display_post($single, $atts);
95
  endforeach;
121
  $cat_link_string = '<a href="' . $cat_link . '" title="' . $cat_title . '">' . $cat_title . '</a>';
122
  }
123
  //Build the query for get_posts()
124
+ $lcp_query = $lcp_category.'&numberposts=' . $atts['numberposts'] .
125
  '&orderby=' . $atts['orderby'] .
126
  '&order=' . $atts['order'] .
127
  '&exclude=' . $atts['excludeposts'] .
128
  '&tag=' . $atts['tags'] .
129
+ '&offset=' . $atts['offset'];
130
+ if($atts['post_type']): $lcp_query .= '&post_type=' . $atts['post_type']; endif;
131
+ if($atts['post_parent']): $lcp_query .= '&post_parent=' . $atts['post_parent']; endif;
132
+
133
+ return get_posts($lcp_query);
134
  }
135
 
136
  function lcp_display_post($single, $atts){
152
  if ($atts['excerpt']!='no' && !($atts['content']=='yes' && $single->post_content) ){
153
  $lcp_output .= lcp_excerpt($single);
154
  }
155
+ if ($atts['thumbnail']=='yes'){
156
+ $lcp_output .= lcp_thumbnail($single);
157
  }
158
  $lcp_output.="</li>";
159
  return $lcp_output;
195
  }
196
 
197
 
198
+ function lcp_thumbnail($single){
199
+ $lcp_thumbnail = '';
200
  if ( has_post_thumbnail($single->ID) ) {
201
+ $lcp_thumbnail = get_the_post_thumbnail($single->ID);
202
  }
203
+ return $lcp_thumbnail;
204
  }
205
 
206
  /** TODO - These are the todo's for a 1.0 release:
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.8
6
  Tested up to: 3.0.1
7
- Stable tag: 0.13.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.
@@ -18,8 +18,7 @@ Compatible with WordPress 3.0 and default Twenty Ten theme (http://wordpress.org
18
  Usage: [catlist argument1=value1 argument2=value2].
19
 
20
  Tell us how you use this plugin!
21
- http://foro.picandocodigo.net/viewtopic.php?f=28&t=261
22
-
23
 
24
  ==Installation==
25
 
@@ -38,7 +37,7 @@ The arguments you can use are:
38
  * **id** - To display posts from a category using the category's id. Ex: [catlist id=24]. You can **include several categories**: Ex: [catlist id=17,24,32] or **exclude** a category with the minus (-)
39
  If you use both arguments (wrong!), List Category Posts will show the posts from the category in 'name'.
40
 
41
- * **tag** - Tag support, you can display posts from a certain tag.
42
 
43
  * **orderby** - To customize the order. Valid values are:
44
  * **author** - Sort by the numeric author IDs.
@@ -69,7 +68,7 @@ If you use both arguments (wrong!), List Category Posts will show the posts from
69
 
70
  * **dateformat** - Format of the date output. Default is get_option('date_format'). Check http://codex.wordpress.org/Formatting_Date_and_Time for possible formats.
71
 
72
- * **template** - File name of template from templates directory without extension. Example: For 'template.php' value is only 'template'. Default is 'default' that means template in code of plugin not in template file, that's an unordered list (ul html tag) with a CSS class: 'lcp_catlist'
73
 
74
  * **excerpt** - Display the post's excerpt. Default is 'no', use excerpt=yes to activate it.
75
 
@@ -83,19 +82,28 @@ If you use both arguments (wrong!), List Category Posts will show the posts from
83
 
84
  * **comments** - Show comments count for each post. Default is 'no'. Ex: [catlist comments=yes].
85
 
86
- * **thumbnails** - Show post thumbnails (http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/). Default is 'no'. Ex: [catlist thumbnails=yes].
 
 
 
 
 
 
87
 
88
- Your comments and feedback are welcome at: http://foro.picandocodigo.net/viewforum.php?f=28
89
 
90
  **New Code is welcome too** :D
91
 
92
  == Frequently Asked Questions ==
93
- * **Instructions** on how to use the plugin: http://foro.picandocodigo.net/viewtopic.php?f=28&t=251
94
- * **Template system** how to customize the way the posts are shown: http://foro.picandocodigo.net/viewtopic.php?f=28&t=253
95
- * **Support forum** & **New feature requests**: http://foro.picandocodigo.net/viewforum.php?f=28
96
 
97
  == Upgrade Notice ==
98
 
 
 
 
99
  = 0.7.2 =
100
  Template system has changed. Now the posts loop must be defined inside the template. Check templates/default.php for an example.
101
 
@@ -107,6 +115,14 @@ Template system has changed. Custom templates should be stored in wordpress them
107
 
108
  == Changelog ==
109
 
 
 
 
 
 
 
 
 
110
  = 0.13.1 =
111
  * Fixed broken dateformat.
112
 
4
  Tags: list, categories, posts, cms
5
  Requires at least: 2.8
6
  Tested up to: 3.0.1
7
+ Stable tag: 0.14
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.
18
  Usage: [catlist argument1=value1 argument2=value2].
19
 
20
  Tell us how you use this plugin!
21
+ http://foro.picandocodigo.net/discussion/261/do-you-like-list-category-posts-read-me
 
22
 
23
  ==Installation==
24
 
37
  * **id** - To display posts from a category using the category's id. Ex: [catlist id=24]. You can **include several categories**: Ex: [catlist id=17,24,32] or **exclude** a category with the minus (-)
38
  If you use both arguments (wrong!), List Category Posts will show the posts from the category in 'name'.
39
 
40
+ * **tags** - Tag support, you can display posts from a certain tag.
41
 
42
  * **orderby** - To customize the order. Valid values are:
43
  * **author** - Sort by the numeric author IDs.
68
 
69
  * **dateformat** - Format of the date output. Default is get_option('date_format'). Check http://codex.wordpress.org/Formatting_Date_and_Time for possible formats.
70
 
71
+ * **template** - File name of template from templates directory without extension. Example: For 'template.php' value is only 'template'. Default is 'default' that means template in code of plugin not in template file, that's an unordered list (ul html tag) with a CSS class. This class can be passed as a parameter or by default it's: 'lcp_catlist'
72
 
73
  * **excerpt** - Display the post's excerpt. Default is 'no', use excerpt=yes to activate it.
74
 
82
 
83
  * **comments** - Show comments count for each post. Default is 'no'. Ex: [catlist comments=yes].
84
 
85
+ * **thumbnail** - Show post thumbnail (http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/). Default is 'no'. Ex: [catlist thumbnail=yes].
86
+
87
+ * **post_type** - The type of post to show. Available options are: post - Default, page, attachment, any - all post types.
88
+
89
+ * **post_parent** - Show only the children of the post with this ID. Default: None.
90
+
91
+ * **class** - CSS class for the default UL generated by the plugin.
92
 
93
+ Your comments and feedback are welcome at: http://foro.picandocodigo.net/categories/list-category-posts
94
 
95
  **New Code is welcome too** :D
96
 
97
  == Frequently Asked Questions ==
98
+ * **Instructions** on how to use the plugin: http://foro.picandocodigo.net/discussion/251/list-category-posts-documentation/
99
+ * **Template system** how to customize the way the posts are shown: http://foro.picandocodigo.net/discussion/253/list-category-posts-using-templates/
100
+ * **Support forum** & **New feature requests**: http://foro.picandocodigo.net/categories/list-category-posts
101
 
102
  == Upgrade Notice ==
103
 
104
+ = 0.13.2 =
105
+ Thumbnail parameter 'thumbnails' changed to 'thumbnail.
106
+
107
  = 0.7.2 =
108
  Template system has changed. Now the posts loop must be defined inside the template. Check templates/default.php for an example.
109
 
115
 
116
  == Changelog ==
117
 
118
+ = 0.14 =
119
+ * Added "post_type" and "post_parent" from the underlining "get_posts()" API to be usable within the short-code. By Martin Crawford, thanks!
120
+ * Added the "class" parameter to style the default ul. You can pass a class name, or the plugin will use "lcp_catlist" bby default. Thanks Chocolaterebel (http://wordpress.org/support/topic/plugin-list-category-posts-sharing-my-own-template-in-lcp).
121
+ * Fixed "tags" parameter on the documentation, it used to say "tag", and the plugin looks for "tags".
122
+
123
+ = 0.13.2 =
124
+ * Fixed thumbnail code, added it to default.php template as example.
125
+
126
  = 0.13.1 =
127
  * Fixed broken dateformat.
128
 
templates/default.php CHANGED
@@ -48,6 +48,10 @@ foreach($catposts as $single):
48
  $lcp_userdata = get_userdata($single->post_author);
49
  $lcp_output .=" - ".$lcp_userdata->display_name;
50
  }
 
 
 
 
51
  //Show content?
52
  if($atts['content']=='yes' && $single->post_content){
53
  $lcpcontent = apply_filters('the_content', $single->post_content); // added to parse shortcodes
48
  $lcp_userdata = get_userdata($single->post_author);
49
  $lcp_output .=" - ".$lcp_userdata->display_name;
50
  }
51
+ //Show thumbnail?
52
+ if($atts['thumbnail']=='yes'){
53
+ $lcp_output .= '<div class="lcp_thumbnail">'. lcp_thumbnails($single) . '</div>';
54
+ }
55
  //Show content?
56
  if($atts['content']=='yes' && $single->post_content){
57
  $lcpcontent = apply_filters('the_content', $single->post_content); // added to parse shortcodes