Version Description
Download this release
Release Info
Developer | fernandobt |
Plugin | List category posts |
Version | 0.4 |
Comparing to | |
See all releases |
Code changes from version 0.3 to 0.4
- lcp_widget_form.php +38 -32
- list_cat_posts.php +36 -22
- list_cat_posts_widget.php +18 -16
- readme.txt +60 -38
lcp_widget_form.php
CHANGED
@@ -1,53 +1,59 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
11 |
?>
|
|
|
|
|
12 |
<p>Category:<br/>
|
13 |
<select name="lcp_widget_categoryid">
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
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 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
</select></p>
|
34 |
<p>Order:<br/>
|
35 |
<select name='lcp_widget_order'>
|
36 |
-
|
37 |
-
|
38 |
</select></p>
|
39 |
|
40 |
<?php
|
41 |
if ($_POST['lcp_widget_submit']){
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
51 |
}
|
52 |
?>
|
53 |
<input type="hidden" id="lcp_widget_submit" name="lcp_widget_submit" value="1" />
|
1 |
<?php
|
2 |
+
$options = get_option("lcp_widget_options");
|
3 |
+
if (!is_array( $options)){
|
4 |
+
$options = array(
|
5 |
+
'lcp_widget_title' => 'Write a title',
|
6 |
+
'lcp_widget_categoryid' => '1',
|
7 |
+
'lcp_widget_limit' => '5',
|
8 |
+
'lcp_widget_orderby' => 'date',
|
9 |
+
'lcp_widget_order' => 'asc'
|
10 |
+
);
|
11 |
+
}
|
12 |
?>
|
13 |
+
<p>Title:<br/>
|
14 |
+
<input type='text' name='lcp_widget_title'></p>
|
15 |
<p>Category:<br/>
|
16 |
<select name="lcp_widget_categoryid">
|
17 |
+
<?php
|
18 |
+
$categories= get_categories();
|
19 |
+
foreach ($categories as $cat) {
|
20 |
+
$option = '<option value="'.$cat->cat_ID.'">';
|
21 |
+
$option .= $cat->cat_name;
|
22 |
+
$option .= '</option>';
|
23 |
+
echo $option;
|
24 |
+
}
|
25 |
+
?>
|
26 |
</select></p>
|
27 |
|
28 |
<p>Number of posts:<br/>
|
29 |
<input type='text' name='lcp_widget_limit'></p>
|
30 |
<p>Order By:<br/>
|
31 |
<select name='lcp_widget_orderby'>
|
32 |
+
<option value='date'>Date</option>
|
33 |
+
<option value='title'>Post title</option>
|
34 |
+
<option value='author'>Author</option>
|
35 |
+
<option value='rand'>Random</option>
|
36 |
</select></p>
|
37 |
<p>Order:<br/>
|
38 |
<select name='lcp_widget_order'>
|
39 |
+
<option value='desc'>Descending</option>
|
40 |
+
<option value='asc'>Ascending</option>
|
41 |
</select></p>
|
42 |
|
43 |
<?php
|
44 |
if ($_POST['lcp_widget_submit']){
|
45 |
+
|
46 |
+
$options['lcp_widget_title']=htmlspecialchars($_POST['lcp_widget_title']);
|
47 |
+
$options['lcp_widget_categoryid']=htmlspecialchars($_POST['lcp_widget_categoryid']);
|
48 |
+
$options['lcp_widget_limit']=htmlspecialchars($_POST['lcp_widget_limit']);
|
49 |
+
$options['lcp_widget_orderby']=htmlspecialchars($_POST['lcp_widget_orderby']);
|
50 |
+
$options['lcp_widget_order']=htmlspecialchars($_POST['lcp_widget_order']);
|
51 |
|
52 |
+
update_option("lcp_widget_title", $options['lcp_widget_title']);
|
53 |
+
update_option("lcp_widget_categoryid", $options['lcp_widget_categoryid']);
|
54 |
+
update_option("lcp_widget_limit", $options['lcp_widget_limit']);
|
55 |
+
update_option("lcp_widget_orderby", $options['lcp_widget_orderby']);
|
56 |
+
update_option("lcp_widget_order", $options['lcp_widget_order']);
|
57 |
}
|
58 |
?>
|
59 |
<input type="hidden" id="lcp_widget_submit" name="lcp_widget_submit" value="1" />
|
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 |
Author: Fernando Briano
|
8 |
Author URI: http://picandocodigo.net/wordpress/
|
9 |
*/
|
@@ -27,34 +27,48 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
27 |
|
28 |
//Shortcode [catlist parameter="value"]
|
29 |
function catlist_func($atts, $content=null) {
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
38 |
}
|
39 |
add_shortcode('catlist', 'catlist_func');
|
40 |
|
41 |
function list_category_posts($atts){
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
function lcp_add_option_page(){
|
57 |
-
|
58 |
}
|
59 |
|
60 |
//Sidebar Widget:
|
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.4
|
7 |
Author: Fernando Briano
|
8 |
Author URI: http://picandocodigo.net/wordpress/
|
9 |
*/
|
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 |
+
'date' => 'no',
|
37 |
+
'author' => 'no'
|
38 |
+
), $atts);
|
39 |
+
return list_category_posts($atts);
|
40 |
}
|
41 |
add_shortcode('catlist', 'catlist_func');
|
42 |
|
43 |
function list_category_posts($atts){
|
44 |
+
$output = "<ul class='lcp_catlist'>";
|
45 |
+
if($atts['name']!='default' && $atts['id']!='0'){
|
46 |
+
$category='category_name='.$atts['name'];
|
47 |
+
}else{
|
48 |
+
$category='category='.$atts['id'];
|
49 |
+
}
|
50 |
+
/*I should check this for the next version: ('category__in' => array(2,6))
|
51 |
+
to allow posts from many categories.
|
52 |
+
http://codex.wordpress.org/Template_Tags/get_posts#Parameters:_WordPress_2.6.2B */
|
53 |
+
|
54 |
+
//Build the query for get_posts()
|
55 |
+
$catposts=get_posts($category.'&numberposts='.$atts['numberposts'].'&orderby='.$atts['orderby'].'&order='.$atts['order']);
|
56 |
+
foreach($catposts as $single):
|
57 |
+
$output .= "<li><a href='".get_permalink($single->ID)."'>".$single->post_title."</a>";
|
58 |
+
if($atts['date']=='yes'){
|
59 |
+
$output.=" - ".$single->post_date;
|
60 |
+
}
|
61 |
+
if($atts['author']=='yes'){
|
62 |
+
$output.=" - ".get_userdata($single->post_author)->user_nicename;
|
63 |
+
}
|
64 |
+
$output.="</li>";
|
65 |
+
endforeach;
|
66 |
+
$output .= "</ul>";
|
67 |
+
return $output;
|
68 |
}
|
69 |
|
70 |
function lcp_add_option_page(){
|
71 |
+
add_options_page('List Category Posts', 'List Category Posts', 'manage_options','list-category-posts/list_cat_posts_options.php');
|
72 |
}
|
73 |
|
74 |
//Sidebar Widget:
|
list_cat_posts_widget.php
CHANGED
@@ -2,28 +2,30 @@
|
|
2 |
//Sidebar Widget file
|
3 |
|
4 |
function lcp_load_widget() {
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
}
|
10 |
|
11 |
function lcp_widget(){//Display
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
23 |
}
|
24 |
|
25 |
function lcp_widget_options(){
|
26 |
-
|
27 |
}
|
28 |
|
29 |
?>
|
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 |
+
$lcp_title = get_option("lcp_widget_title");
|
13 |
+
$lcp_id = get_option("lcp_widget_categoryid");
|
14 |
+
$lcp_limit = get_option("lcp_widget_limit");
|
15 |
+
$lcp_orderby=get_option("lcp_widget_orderby");
|
16 |
+
$lcp_order=get_option("lcp_widget_order");
|
17 |
+
$lcp_result = '<h2>'.$lcp_title.'</h2><ul class="lcp_catlist">';
|
18 |
+
$lcp_catposts = get_posts('category='.$lcp_id.'&numberposts='.$lcp_limit.'&orderby='.$lcp_orderby.'&order='.$lcp_order);
|
19 |
+
|
20 |
+
foreach($lcp_catposts as $lcp_single):
|
21 |
+
$lcp_result.='<li><a href="'.get_permalink($lcp_single->ID).'">'.$lcp_single->post_title.'</a></li>';
|
22 |
+
endforeach;
|
23 |
+
$lcp_result .= "</ul>";
|
24 |
+
echo $lcp_result;
|
25 |
}
|
26 |
|
27 |
function lcp_widget_options(){
|
28 |
+
include('lcp_widget_form.php');
|
29 |
}
|
30 |
|
31 |
?>
|
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.5
|
6 |
-
Tested up to: 2.
|
7 |
-
Stable tag: 0.
|
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.
|
@@ -23,54 +23,76 @@ Usage: [catlist argument1=value1 argument2=value2].
|
|
23 |
|
24 |
**Usage**
|
25 |
The arguments you can use are:
|
26 |
-
|
27 |
-
'
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
* '
|
32 |
-
* '
|
33 |
-
* '
|
34 |
-
* '
|
35 |
-
* '
|
36 |
-
* '
|
37 |
-
* '
|
38 |
-
* '
|
39 |
-
* '
|
40 |
-
* '
|
41 |
-
* '
|
42 |
-
* '
|
43 |
-
* '
|
44 |
-
* '
|
45 |
-
* '
|
46 |
-
Ex: [catlist name=mycategory orderby=date]
|
47 |
-
|
48 |
-
'
|
49 |
-
* '
|
50 |
-
|
51 |
-
Ex: [catlist name=mycategory
|
52 |
-
|
53 |
-
'
|
54 |
-
|
|
|
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.
|
|
|
|
|
59 |
|
60 |
-
List category posts was written with Geany - http://geany.uvena.de
|
|
|
61 |
|
62 |
**Changelog**
|
63 |
|
64 |
-
0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
|
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.7
|
7 |
+
Stable tag: 0.4
|
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.
|
23 |
|
24 |
**Usage**
|
25 |
The arguments you can use are:
|
26 |
+
|
27 |
+
* 'name' - To display posts from a category using the category's name. Ex: [catlist name=mycategory]
|
28 |
+
|
29 |
+
* 'id' - To display posts from a category using the category's id. Ex: [catlist id=24]. If you use both arguments (wrong!), List Category Posts will show the posts from the category in 'name'.
|
30 |
+
|
31 |
+
* 'orderby' - To customize the order. Valid values are:
|
32 |
+
* 'author' - Sort by the numeric author IDs.
|
33 |
+
* 'category' - Sort by the numeric category IDs.
|
34 |
+
* 'content' - Sort by content.
|
35 |
+
* 'date' - Sort by creation date.
|
36 |
+
* 'ID' - Sort by numeric post ID.
|
37 |
+
* 'menu_order' - Sort by the menu order. Only useful with pages.
|
38 |
+
* 'mime_type' - Sort by MIME type. Only useful with attachments.
|
39 |
+
* 'modified' - Sort by last modified date.
|
40 |
+
* 'name' - Sort by stub.
|
41 |
+
* 'parent' - Sort by parent ID.
|
42 |
+
* 'password' - Sort by password.
|
43 |
+
* 'rand' - Randomly sort results.
|
44 |
+
* 'status' - Sort by status.
|
45 |
+
* 'title' - Sort by title.
|
46 |
+
* 'type' - Sort by type. Ex: [catlist name=mycategory orderby=date]
|
47 |
+
* 'order' - How to sort 'orderby'. Valid values are:
|
48 |
+
* 'ASC' - Ascending (lowest to highest).
|
49 |
+
* 'DESC' - Descending (highest to lowest). Ex: [catlist name=mycategory orderby=title order=asc]
|
50 |
+
|
51 |
+
* '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. Ex: [catlist name=mycategory numberposts=10]
|
52 |
+
|
53 |
+
* 'date' - Display the date of the post next to the title. Default is 'no', use date=yes to activate it.
|
54 |
+
|
55 |
+
* 'author' - Display the author of the post next to the title. Default is 'no', use author=yes to activate it.
|
56 |
|
57 |
You can customize the way List Category Posts shows the posts in your CSS by editing "lcp_catlist".
|
58 |
|
59 |
+
Since version 0.2, List Category Posts includes a sidebar widget. It works pretty much the same as the plugin itself.
|
60 |
+
|
61 |
+
Your comments and feedback are welcome at: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/
|
62 |
|
63 |
+
List category posts was written initially with Geany - http://geany.uvena.de/.
|
64 |
+
Now it's being written with GNU Emacs - http://www.gnu.org/software/emacs/
|
65 |
|
66 |
**Changelog**
|
67 |
|
68 |
+
**0.4**
|
69 |
+
|
70 |
+
* Added 'date' parameter. Now you can show the post's date when listed.
|
71 |
+
|
72 |
+
* Added 'author' parameter. You can also show the post's author.
|
73 |
+
|
74 |
+
* Sidebar Widget now allows you to add a title in h2 tags.
|
75 |
+
|
76 |
+
* Changed some variable names, to keep better compatibility with other plugins/wordpress variables.
|
77 |
+
|
78 |
+
* Tested with Wordpress 2.7.
|
79 |
+
|
80 |
+
**0.3**
|
81 |
+
|
82 |
* Broke backwards compatibility. Users of version 0.1 should update their pages and posts for the new shortcode formatting.
|
83 |
+
|
84 |
* 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.
|
85 |
|
86 |
+
**0.2**
|
87 |
+
|
88 |
* Added experimental sidebar widget (use at your own risk, not ready for prime-time yet since it hasn't been tested :P )
|
89 |
|
90 |
+
**0.1.1**
|
91 |
+
|
92 |
* Fixed major bug, which gave 404 error when trying to use "Options" page.
|
93 |
|
94 |
+
**0.1**
|
95 |
+
|
96 |
* Option page to limit number of posts.
|
97 |
+
|
98 |
+
* Working using [category=ID] for posts and pages, with several categories support.
|