List category posts - Version 0.7

Version Description

  • Exclude posts. Contribution by acub.
  • Offset parameter on shortcode to start listing posts with an offset. Contribution by Levi Vasquez
  • Content of the post can now be displayed. Contribution by Lang Zerner.
  • Link to the category available. By request on the plugin's forum.
Download this release

Release Info

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

Code changes from version 0.6 to 0.7

Files changed (3) hide show
  1. list_cat_posts.php +25 -8
  2. readme.txt +20 -5
  3. templates/default.php +11 -6
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.6
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/wordpress/
9
  */
@@ -35,26 +35,40 @@ function catlist_func($atts, $content=null) {
35
  'numberposts' => '5',
36
  'date' => 'no',
37
  'author' => 'no',
38
- 'dateformat' => get_option('date_format'), //By Verex
39
  'template' => 'default',
40
  'excerpt' => 'no',
41
- 'exclude' => '0'
 
 
 
42
  ), $atts);
43
  return list_category_posts($atts);
44
  }
45
  add_shortcode('catlist', 'catlist_func');
46
 
47
  function list_category_posts($atts){
48
- if($atts['name']!='default' && $atts['id']!='0'){
49
  $category = 'category_name=' . $atts['name'];
 
50
  }else{
51
  $category = 'cat=' . $atts['id'];
 
 
 
 
 
 
 
 
 
52
  }
53
  //Build the query for get_posts()
54
  $catposts = get_posts($category.'&numberposts=' . $atts['numberposts'] .
55
  '&orderby=' . $atts['orderby'] .
56
- '&order=' . $atts['order']);
57
-
 
58
  //Template code:
59
  $tplFileName= $atts['template'] != 'default'?dirname(__FILE__).'/templates/'.$atts['template'].'.php' : null;
60
  if ((!empty($tplFileName)) && (is_readable($tplFileName))) {
@@ -76,11 +90,14 @@ function list_category_posts($atts){
76
  $lcp_userdata = get_userdata($single->post_author);
77
  $output.=" - ".$lcp_userdata->user_nicename . '<br/>';
78
  }
79
- if($atts['excerpt']=='yes' && ($single->post_excerpt)){
 
 
 
80
  $output .= "<p>$single->post_excerpt</p>";
81
  }
82
  $output.="</li>";
83
- }
84
  endforeach;
85
  if(!$lcpTemplate): $output .= "</ul>"; endif;
86
  return $output;
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
7
  Author: Fernando Briano
8
  Author URI: http://picandocodigo.net/wordpress/
9
  */
35
  'numberposts' => '5',
36
  'date' => 'no',
37
  'author' => 'no',
38
+ 'dateformat' => get_option('date_format'),
39
  'template' => 'default',
40
  'excerpt' => 'no',
41
+ 'exclude' => '0',
42
+ 'excludeposts' => '0',
43
+ 'offset' => '4',
44
+ 'catlink' => 'no'
45
  ), $atts);
46
  return list_category_posts($atts);
47
  }
48
  add_shortcode('catlist', 'catlist_func');
49
 
50
  function list_category_posts($atts){
51
+ if($atts['name']!='default' && $atts['id']=='0'){
52
  $category = 'category_name=' . $atts['name'];
53
+ $category_id = get_cat_ID($atts['name']);
54
  }else{
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'] .
68
  '&orderby=' . $atts['orderby'] .
69
+ '&order=' . $atts['order'] .
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))) {
90
  $lcp_userdata = get_userdata($single->post_author);
91
  $output.=" - ".$lcp_userdata->user_nicename . '<br/>';
92
  }
93
+ if($atts['content']=='yes' && $single->post_content){
94
+ $output .= "<p>$single->post_content</p>";
95
+ }
96
+ if($atts['excerpt']=='yes' && $single->post_excerpt && !($atts['content']=='yes' && $single->post_content) ){
97
  $output .= "<p>$single->post_excerpt</p>";
98
  }
99
  $output.="</li>";
100
+ }
101
  endforeach;
102
  if(!$lcpTemplate): $output .= "</ul>"; endif;
103
  return $output;
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: fernandobt
3
  Donate Link: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
4
  Tags: list, categories, posts, cms
5
  Requires at least: 2.6
6
- Tested up to: 2.8.4
7
- Stable tag: 0.6
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.
@@ -14,7 +14,7 @@ Usage: [catlist argument1=value1 argument2=value2].
14
 
15
  * Upload listcat directory into you wp-content/plugins/ directory.
16
  * Login to your WordPress Admin menu, go to Plugins, and activate it.
17
- * Add "lcp_catlist" class into your theme’s CSS for custom formatting, or create a new php file in templates directory and use it as a parameter.
18
  * You can find the List Category Posts widget in your widgets. Hasn't been tested, still in development, but usable.
19
 
20
  **If you're updating List Category Posts from version 0.1**, you must change the code in the pages using it, since it's not backwards compatible. LCP now uses WordPress's shortcode API, in order to allow arguments. You should chang the previous [catlist=ID] to [catlist id=ID].
@@ -61,6 +61,14 @@ If you use both arguments (wrong!), List Category Posts will show the posts from
61
 
62
  * **excerpt** - Display the post's excerpt. Default is 'no', use excerpt=yes to activate it.
63
 
 
 
 
 
 
 
 
 
64
  Since version 0.2, List Category Posts includes a sidebar widget. It works pretty much the same as the plugin itself.
65
 
66
  Your comments and feedback are welcome at: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
@@ -68,11 +76,18 @@ Your comments and feedback are welcome at: http://picandocodigo.net/programacion
68
  **New Code is welcome** :D
69
 
70
  == Frequently Asked Questions ==
71
- Got any question?
72
- http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
 
73
 
74
  == Changelog ==
75
 
 
 
 
 
 
 
76
  = 0.6 =
77
  * Minor fix for unclosed ul if not using templates.
78
  * Added option to list posts from many categories at once.
3
  Donate Link: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
4
  Tags: list, categories, posts, cms
5
  Requires at least: 2.6
6
+ Tested up to: 2.9
7
+ Stable tag: 0.7
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.
14
 
15
  * Upload listcat directory into you wp-content/plugins/ directory.
16
  * Login to your WordPress Admin menu, go to Plugins, and activate it.
17
+ * Edit the default.php file on templates to customize the way the categories are displayed, or use the default one included in the plugin's code. You can use several different templates if you want.
18
  * You can find the List Category Posts widget in your widgets. Hasn't been tested, still in development, but usable.
19
 
20
  **If you're updating List Category Posts from version 0.1**, you must change the code in the pages using it, since it's not backwards compatible. LCP now uses WordPress's shortcode API, in order to allow arguments. You should chang the previous [catlist=ID] to [catlist id=ID].
61
 
62
  * **excerpt** - Display the post's excerpt. Default is 'no', use excerpt=yes to activate it.
63
 
64
+ * **excludeposts** - IDs of posts to exclude from the list. Ex: [catlist excludeposts=12,52,37]
65
+
66
+ * **offset** - You can displace or pass over one or more initial posts which would normally be collected by your query through the use of the offset parameter.
67
+
68
+ * **content** - Show the full content of the post. Default is 'no'. Ex: [catlist content=yes]
69
+
70
+ * **catlink** - Show the link to the category. Use the template system to customize its display using the variable $cat_link_string. Default is 'no'. Ex: [catlist catlink=yes].
71
+
72
  Since version 0.2, List Category Posts includes a sidebar widget. It works pretty much the same as the plugin itself.
73
 
74
  Your comments and feedback are welcome at: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
76
  **New Code is welcome** :D
77
 
78
  == Frequently Asked Questions ==
79
+ * **Instructions** on how to use the plugin: http://wordpress.org/extend/plugins/list-category-posts/other_notes/
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 =
86
+ * Exclude posts. Contribution by acub.
87
+ * Offset parameter on shortcode to start listing posts with an offset. Contribution by Levi Vasquez
88
+ * Content of the post can now be displayed. Contribution by Lang Zerner.
89
+ * Link to the category available. By request on the plugin's forum.
90
+
91
  = 0.6 =
92
  * Minor fix for unclosed ul if not using templates.
93
  * Added option to list posts from many categories at once.
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.2
7
  Author: Radek Uldrych & Fernando Briano
8
  Author URI: http://picandocodigo.net http://radoviny.net
9
  */
@@ -24,19 +24,24 @@ 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 .= "<li><a href='".get_permalink($single->ID)."'>".$single->post_title."</a>";
 
28
  //Style for date:
29
  if($atts['date']=='yes'){
30
- $output.=" - ".get_the_time($atts['dateformat'], $single);
31
  }
32
  //Show author?
33
  if($atts['author']=='yes'){
34
  $lcp_userdata = get_userdata($single->post_author);
35
  $output.=" - ".$lcp_userdata->user_nicename;
36
  }
 
 
 
 
37
  //Show excerpt?
38
- if($atts['excerpt']=='yes' && ($single->post_excerpt)){
39
- $output .= "<p>$single->post_excerpt</p>";
40
  }
41
- $output.="</li>";
42
  ?>
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
  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'){
31
+ $output.= ' - ' . get_the_time($atts['dateformat'], $single);
32
  }
33
  //Show author?
34
  if($atts['author']=='yes'){
35
  $lcp_userdata = get_userdata($single->post_author);
36
  $output.=" - ".$lcp_userdata->user_nicename;
37
  }
38
+ //Show content?
39
+ if($atts['content']=='yes' && $single->post_content){
40
+ $output .= "<p>$single->post_content</p>";
41
+ }
42
  //Show excerpt?
43
+ if($atts['excerpt']=='yes' && $single->post_excerpt && !($atts['content']=='yes' && $single->post_content) ){
44
+ $output .= '<p>' . $single->post_excerpt . '</p>';
45
  }
46
+ $output.='</li>';
47
  ?>