Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds year and month parameters to list posts from a certain year and/…

…or month, fixes #21

Adds search parameter to display posts that match a search term.
  • Loading branch information...
commit 490f7584a9eeec971b06249a0baf48a3ab38e427 1 parent 77d662f
@picandocodigo authored
Showing with 34 additions and 6 deletions.
  1. +17 −2 include/CatList.php
  2. +5 −2 list_cat_posts.php
  3. +12 −2 readme.txt
View
19 include/CatList.php
@@ -54,12 +54,27 @@ private function set_lcp_parameters(){
$args['post_status'] = $this->params['post_status'];
endif;
-
if(isset($this->params['post_parent']) &&
- $this->params['post_parent'] != '0'):
+ $this->params['post_parent'] != '0'):
$args['post_parent'] = $this->params['post_parent'];
endif;
+ if(isset($this->params['year']) &&
+ $this->params['year'] != ''):
+ $args['year'] = $this->params['year'];
+ endif;
+
+ if(isset($this->params['monthnum']) &&
+ $this->params['monthnum'] != ''):
+ $args['monthnum'] = $this->params['monthnum'];
+ endif;
+
+ if(isset($this->params['search']) &&
+ $this->params['search'] != ''):
+ $args['s'] = $this->params['search'];
+ endif;
+
+
/*
* Custom fields 'customfield_name' & 'customfield_value'
* should both be defined
View
7 list_cat_posts.php
@@ -3,7 +3,7 @@
Plugin Name: List category posts
Plugin URI: https://github.com/picandocodigo/List-Category-Posts
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].
- Version: 0.26
+ Version: 0.27
Author: Fernando Briano
Author URI: http://picandocodigo.net/
@@ -87,7 +87,10 @@ function catlist_func($atts, $content = null) {
'taxonomy' => '',
'categorypage' => '',
'morelink' => '',
- 'morelink_class' => ''
+ 'morelink_class' => '',
+ 'year' => '',
+ 'monthnum' => '',
+ 'search' => ''
), $atts);
$catlist_displayer = new CatListDisplayer($atts);
View
14 readme.txt
@@ -4,7 +4,7 @@ Donate Link: http://picandocodigo.net/programacion/wordpress/list-category-posts
Tags: list, categories, posts, cms
Requires at least: 2.8
Tested up to: 3.5
-Stable tag: 0.26
+Stable tag: 0.27
== Description ==
List Category Posts allows you to list posts from a category into a post/page using the [catlist] shortcode.
@@ -87,6 +87,10 @@ You can use the *categorypage* parameter to make it detect the category id of th
* **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]
+* **monthnum** and **year** - List posts from a certain year or month. You can use these together or independently. Example: `[catlist year=2015]` will list posts from the year 2015. `[catlist monthnum=8]` will list posts published in August of every year. `[catlist year=2012 month=12]` will list posts from December 2012.
+
+* **search** - List posts that match a search term. `[catlist search="The Cake is a lie"]`
+
* **date** - Display post's date next to the title. Default is 'no', use date=yes to activate it.
* **author** - Display the post's author next to the title. Default is 'no', use author=yes to activate it.
@@ -187,7 +191,7 @@ http://wordpress.stackexchange.com/questions/9338/list-category-posts-plugin-upg
== Upgrade Notice ==
= 0.25 =
-* translation support
+* Translation support.
= 0.18 =
Template system was upgraded with new options. Backwards compatible, but you can better customize the way the post contents are displayed. Check templates/default.php.
@@ -209,6 +213,12 @@ Template system has changed. Custom templates should be stored in WordPress them
== Changelog ==
+= 0.27 =
+
+ * Fixes to widget.
+ * Adds year and month parameters to list posts from a certain year and/or month.
+ * Adds search parameter to display posts that match a search term.
+
= 0.26 =
* Adds i18n, German and Spanish translations. All credit to [cfoellmann](https://github.com/cfoellmann) for implementing this and writing the German translation. Thanks! :)
Please sign in to comment.
Something went wrong with that request. Please try again.