Version Description
Download this release
Release Info
Developer | fernandobt |
Plugin | List category posts |
Version | 0.3 |
Comparing to | |
See all releases |
Code changes from version 0.1.1 to 0.3
- lcp_widget_form.php +53 -0
- list_cat_posts.php +34 -31
- list_cat_posts_options.php +0 -21
- list_cat_posts_widget.php +29 -0
- readme.txt +58 -18
lcp_widget_form.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$options = get_option("lcp_widget_options");
|
3 |
+
if (!is_array( $options)){
|
4 |
+
$options = array(
|
5 |
+
'lcp_widget_categoryid' => '1',
|
6 |
+
'lcp_widget_limit' => '5',
|
7 |
+
'lcp_widget_orderby' => 'date',
|
8 |
+
'lcp_widget_order' => 'asc'
|
9 |
+
);
|
10 |
+
}
|
11 |
+
?>
|
12 |
+
<p>Category:<br/>
|
13 |
+
<select name="lcp_widget_categoryid">
|
14 |
+
<?php
|
15 |
+
$categories= get_categories();
|
16 |
+
foreach ($categories as $cat) {
|
17 |
+
$option = '<option value="'.$cat->cat_ID.'">';
|
18 |
+
$option .= $cat->cat_name;
|
19 |
+
$option .= '</option>';
|
20 |
+
echo $option;
|
21 |
+
}
|
22 |
+
?>
|
23 |
+
</select></p>
|
24 |
+
|
25 |
+
<p>Number of posts:<br/>
|
26 |
+
<input type='text' name='lcp_widget_limit'></p>
|
27 |
+
<p>Order By:<br/>
|
28 |
+
<select name='lcp_widget_orderby'>
|
29 |
+
<option value='date'>Date</option>
|
30 |
+
<option value='title'>Post title</option>
|
31 |
+
<option value='author'>Author</option>
|
32 |
+
<option value='rand'>Random</option>
|
33 |
+
</select></p>
|
34 |
+
<p>Order:<br/>
|
35 |
+
<select name='lcp_widget_order'>
|
36 |
+
<option value='desc'>Descending</option>
|
37 |
+
<option value='asc'>Ascending</option>
|
38 |
+
</select></p>
|
39 |
+
|
40 |
+
<?php
|
41 |
+
if ($_POST['lcp_widget_submit']){
|
42 |
+
$options['lcp_widget_categoryid']=htmlspecialchars($_POST['lcp_widget_categoryid']);
|
43 |
+
$options['lcp_widget_limit']=htmlspecialchars($_POST['lcp_widget_limit']);
|
44 |
+
$options['lcp_widget_orderby']=htmlspecialchars($_POST['lcp_widget_orderby']);
|
45 |
+
$options['lcp_widget_order']=htmlspecialchars($_POST['lcp_widget_order']);
|
46 |
+
|
47 |
+
update_option("lcp_widget_categoryid", $options['lcp_widget_categoryid']);
|
48 |
+
update_option("lcp_widget_limit", $options['lcp_widget_limit']);
|
49 |
+
update_option("lcp_widget_orderby", $options['lcp_widget_orderby']);
|
50 |
+
update_option("lcp_widget_order", $options['lcp_widget_order']);
|
51 |
+
}
|
52 |
+
?>
|
53 |
+
<input type="hidden" id="lcp_widget_submit" name="lcp_widget_submit" value="1" />
|
list_cat_posts.php
CHANGED
@@ -1,9 +1,9 @@
|
|
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
|
6 |
-
Version: 0.
|
7 |
Author: Fernando Briano
|
8 |
Author URI: http://picandocodigo.net/wordpress/
|
9 |
*/
|
@@ -25,38 +25,41 @@ 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 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
$replace= $output;
|
48 |
-
$content= str_replace ($search, $replace, $content);
|
49 |
-
}
|
50 |
-
}
|
51 |
-
}
|
52 |
}
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
function lcp_add_option_page(){
|
57 |
-
add_options_page('Category
|
58 |
}
|
59 |
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
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 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.3
|
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 |
+
//Shortcode [catlist parameter="value"]
|
29 |
+
function catlist_func($atts, $content=null) {
|
30 |
+
$atts=shortcode_atts(array(
|
31 |
+
'id' => '0',
|
32 |
+
'name' => 'default',
|
33 |
+
'orderby' => 'date',
|
34 |
+
'order' => 'desc',
|
35 |
+
'numberposts' => '5'
|
36 |
+
), $atts);
|
37 |
+
return list_category_posts($atts);
|
38 |
+
}
|
39 |
+
add_shortcode('catlist', 'catlist_func');
|
40 |
+
|
41 |
+
function list_category_posts($atts){
|
42 |
+
$output = "<ul class='lcp_catlist'>";
|
43 |
+
if($atts['name']!='default' && $atts['id']!='0'){
|
44 |
+
$category='category_name='.$atts['name'];
|
45 |
+
}else{
|
46 |
+
$category='category='.$atts['id'];
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
+
$catposts=get_posts($category.'&numberposts='.$atts['numberposts'].'&orderby='.$atts['orderby'].'&order='.$atts['order']);
|
49 |
+
foreach($catposts as $single):
|
50 |
+
$output .= "<li><a href='".get_permalink($single->ID)."'>".$single->post_title."</a></li>";
|
51 |
+
endforeach;
|
52 |
+
$output .= "</ul>";
|
53 |
+
return $output;
|
54 |
}
|
55 |
|
56 |
function lcp_add_option_page(){
|
57 |
+
add_options_page('List Category Posts', 'List Category Posts', 'manage_options','list-category-posts/list_cat_posts_options.php');
|
58 |
}
|
59 |
|
60 |
+
//Sidebar Widget:
|
61 |
+
include('list_cat_posts_widget.php');
|
62 |
+
//Filters and actions:
|
63 |
+
add_action('plugins_loaded', 'lcp_load_widget');
|
64 |
+
|
65 |
?>
|
list_cat_posts_options.php
DELETED
@@ -1,21 +0,0 @@
|
|
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list_cat_posts_widget.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//Sidebar Widget file
|
3 |
+
|
4 |
+
function lcp_load_widget() {
|
5 |
+
if (function_exists('register_sidebar_widget')) {
|
6 |
+
register_sidebar_widget('List category posts', 'lcp_widget');
|
7 |
+
register_widget_control('List category posts', 'lcp_widget_options', 300, 200 );
|
8 |
+
}
|
9 |
+
}
|
10 |
+
|
11 |
+
function lcp_widget(){//Display
|
12 |
+
$id = get_option("lcp_widget_categoryid");
|
13 |
+
$limit = get_option("lcp_widget_limit");
|
14 |
+
$orderby=get_option("lcp_widget_orderby");
|
15 |
+
$order=get_option("lcp_widget_order");
|
16 |
+
$result = '<ul class="lcp_catlist">';
|
17 |
+
$catposts = get_posts('category='.$id.'&numberposts='.$limit.'&orderby='.$orderby.'&order='.$order);
|
18 |
+
foreach($catposts as $single):
|
19 |
+
$result.='<li><a href="'.get_permalink($single->ID).'">'.$single->post_title.'</a></li>';
|
20 |
+
endforeach;
|
21 |
+
$result .= "</ul>";
|
22 |
+
echo $result;
|
23 |
+
}
|
24 |
+
|
25 |
+
function lcp_widget_options(){
|
26 |
+
include('lcp_widget_form.php');
|
27 |
+
}
|
28 |
+
|
29 |
+
?>
|
readme.txt
CHANGED
@@ -2,35 +2,75 @@
|
|
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.
|
6 |
Tested up to: 2.6
|
7 |
-
Stable tag: 0.
|
8 |
|
9 |
== Description ==
|
10 |
-
List Category Posts is a simple WordPress plugin which allows you to list
|
11 |
-
|
12 |
|
13 |
-
|
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 |
-
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
|
20 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
0.1.1
|
32 |
-
|
33 |
|
34 |
0.1
|
35 |
-
|
36 |
-
|
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.5
|
6 |
Tested up to: 2.6
|
7 |
+
Stable tag: 0.3
|
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.
|
11 |
+
Usage: [catlist argument1=value1 argument2=value2].
|
12 |
|
13 |
+
==Installation==
|
|
|
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.
|
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].
|
21 |
|
22 |
+
==Other notes==
|
|
|
|
|
|
|
23 |
|
24 |
+
**Usage**
|
25 |
+
The arguments you can use are:
|
26 |
+
'name' - To display posts from a category using the category's name. Ex: [catlist name=mycategory]
|
27 |
+
'id' - To display posts from a category using the category's id. Ex: [catlist id=24]
|
28 |
+
If you use both arguments (wrong!), List Category Posts will show the posts from the category in 'name'.
|
29 |
|
30 |
+
'orderby' - To customize the order. Valid values are:
|
31 |
+
* 'author' - Sort by the numeric author IDs.
|
32 |
+
* 'category' - Sort by the numeric category IDs.
|
33 |
+
* 'content' - Sort by content.
|
34 |
+
* 'date' - Sort by creation date.
|
35 |
+
* 'ID' - Sort by numeric post ID.
|
36 |
+
* 'menu_order' - Sort by the menu order. Only useful with pages.
|
37 |
+
* 'mime_type' - Sort by MIME type. Only useful with attachments.
|
38 |
+
* 'modified' - Sort by last modified date.
|
39 |
+
* 'name' - Sort by stub.
|
40 |
+
* 'parent' - Sort by parent ID.
|
41 |
+
* 'password' - Sort by password.
|
42 |
+
* 'rand' - Randomly sort results.
|
43 |
+
* 'status' - Sort by status.
|
44 |
+
* 'title' - Sort by title.
|
45 |
+
* 'type' - Sort by type.
|
46 |
+
Ex: [catlist name=mycategory orderby=date]
|
47 |
|
48 |
+
'order' - How to sort 'orderby'. Valid values are:
|
49 |
+
* 'ASC' - Ascending (lowest to highest).
|
50 |
+
* 'DESC' - Descending (highest to lowest).
|
51 |
+
Ex: [catlist name=mycategory orderby=title order=asc]
|
52 |
+
|
53 |
+
'numberposts' - Number of posts to return. Set to 0 to use the max number of posts per page. Set to -1 to remove the limit. Default: 5
|
54 |
+
Ex: [catlist name=mycategory numberposts=10]
|
55 |
+
|
56 |
+
You can customize the way List Category Posts shows the posts in your CSS by editing "lcp_catlist".
|
57 |
+
|
58 |
+
Since version 0.2, List Category Posts includes a sidebar widget. This is still in development, since I dedicated more time to the arguments in [catlist]. It does work, but you're welcome to test it and comment your feedback at: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
|
59 |
+
|
60 |
+
List category posts was written with Geany - http://geany.uvena.de/
|
61 |
+
|
62 |
+
**Changelog**
|
63 |
+
|
64 |
+
0.3
|
65 |
+
* Broke backwards compatibility. Users of version 0.1 should update their pages and posts for the new shortcode formatting.
|
66 |
+
* Option to pass arguments to the plugin, in order to use name of category instead of ID, orderby, order and number of posts are passed through parameters.
|
67 |
+
|
68 |
+
0.2
|
69 |
+
* Added experimental sidebar widget (use at your own risk, not ready for prime-time yet since it hasn't been tested :P )
|
70 |
|
71 |
0.1.1
|
72 |
+
* Fixed major bug, which gave 404 error when trying to use "Options" page.
|
73 |
|
74 |
0.1
|
75 |
+
* Option page to limit number of posts.
|
76 |
+
* Working using [category=ID] for posts and pages, with several categories support.
|