List category posts - Version 0.1

Version Description

Download this release

Release Info

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

Version 0.1

Files changed (3) hide show
  1. list_cat_posts.php +62 -0
  2. list_cat_posts_options.php +21 -0
  3. readme.txt +27 -0
list_cat_posts.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
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 is a simple WordPress plugin which allows you to list some posts from a category into a post/page using [catlist=ID], where ID stands for the Category Id. You can list several categories on the same page/post. You can use [catlist=ID] as many times as needed with different Id’s. You may also define a limit of posts to show. Great to use WordPress as a CMS, and create pages with several categories posts. <br/><br/>Inspired by Category Page: http://wordpress.org/extend/plugins/page2cat/<br/>Category Page is a good plugin, but too complicated and big for what I needed. I just needed to list posts from a certain category, and be able to use several category id's to list on one page.
6
+ Version: 0.1
7
+ Author: Fernando Briano
8
+ Author URI: http://picandocodigo.net/wordpress/
9
+ */
10
+
11
+ /* Copyright 2008 Fernando Briano (email : transformers.es@gmail.com)
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
15
+ the Free Software Foundation; either version 3 of the License, or
16
+ any later version.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ 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
+
28
+ /*The following code is based on code from: Category Page: http://wordpress.org/extend/plugins/page2cat/
29
+ * Pixline - http://pixline.net/ */
30
+ // filter the content of a page, check for tag and replace it with a list of posts in the requested category.
31
+ // function heavily inspired from Alex Rabe NextGen Gallery's nggfunctions.php.
32
+ function list_category_posts($content){
33
+ global $post;
34
+ if ( stristr( $content, '[catlist' )) {
35
+ $search = "@(?:<p>)*\s*\[catlist\s*=\s*(\w+|^\+)\]\s*(?:</p>)*@i";
36
+ if (preg_match_all($search, $content, $matches)) {
37
+ if (is_array($matches)) {
38
+ $limit = get_option('lcp_limit');
39
+ foreach ($matches[1] as $key =>$v0) {
40
+ $output = "<ul class='lcp_catlist'>";
41
+ $catposts = get_posts('category='.$v0."&numberposts=".$limit);
42
+ foreach($catposts as $single):
43
+ $output .= "<li><a href='".get_permalink($single->ID)."'>".$single->post_title."</a></li>";
44
+ endforeach;
45
+ $search = $matches[0][$key];
46
+ $output .= "</ul>";
47
+ $replace= $output;
48
+ $content= str_replace ($search, $replace, $content);
49
+ }
50
+ }
51
+ }
52
+ }
53
+ return $content;
54
+ }
55
+
56
+ function lcp_add_option_page(){
57
+ add_options_page('Category List', 'Category List', 'manage_options','listcat/list_cat_posts_options.php');
58
+ }
59
+
60
+ add_filter('the_content','list_category_posts');
61
+ add_action('admin_head', 'lcp_add_option_page');
62
+ ?>
list_cat_posts_options.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <form method="post" action="options.php">
2
+ <?php
3
+ wp_nonce_field('update-options');
4
+ $limit=get_option('lcp_limit');
5
+ if($limit=="")
6
+ $limit=5
7
+ ?>
8
+ <table>
9
+ <tr>
10
+ <td>Posts limit:
11
+ </td>
12
+ <td><input type="text" name="lcp_limit" value="<?php echo $limit; ?>">
13
+ </td>
14
+ </tr>
15
+ </table>
16
+ <input type="hidden" name="action" value="update" />
17
+ <input type="hidden" name="page_options" value="lcp_limit" />
18
+ <p class="submit">
19
+ <input type="submit" name="Submit" value="<?php _e('Save Changes') ?>" />
20
+ </p>
21
+ </form>
readme.txt ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === List category posts ===
2
+ 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.0
6
+ Tested up to: 2.6
7
+ Stable tag: 0.1
8
+
9
+ == Description ==
10
+ List Category Posts is a simple WordPress plugin which allows you to list some posts from a category into a post/page using [catlist=ID], where ID stands for the Category Id. You can list several categories on the same page/post. You can use [catlist=ID] as many times as needed with different Id’s. You may also define a limit of posts to show.
11
+ Great to use WordPress as a CMS, and create pages with several categories posts.
12
+
13
+ Inspired by Category Page: http://wordpress.org/extend/plugins/page2cat/
14
+ Category Page is a good plugin, but too complicated and big for what I needed. I just needed to list posts from a certain category, and be able to use several category id's to list on one page.
15
+
16
+ List category posts was written with Geany - http://geany.uvena.de/
17
+
18
+ ==Installation==
19
+
20
+ * Upload listcat directory into you wp-content/plugins/ directory.
21
+ * Login to your WordPress Admin menu, go to Plugins, and activate it.
22
+ * On Settings / Category List, input the post limit (how many posts you want it to display). Default is 5.
23
+ * Add “lcp_catlist” class into your theme’s CSS for custom formatting.
24
+
25
+ ==Usage==
26
+
27
+ When writing a post/page, use [catlist=ID] where ID is the Id for a specific category. You can change the way List Category Posts shows the posts in your CSS by editing "lcp_catlist". The generated code is: <ul class="lcp_catlist">, and a <li> for each post in the category.