Skip to content

Commit

Permalink
Adds year and month parameters to list posts from a certain year and/…
Browse files Browse the repository at this point in the history
…or month, fixes #21

Adds search parameter to display posts that match a search term.
  • Loading branch information
picandocodigo committed Dec 27, 2012
1 parent 77d662f commit 490f758
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
19 changes: 17 additions & 2 deletions include/CatList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions list_cat_posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 12 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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! :)
Expand Down

0 comments on commit 490f758

Please sign in to comment.