List category posts - Version 0.79

Version Description

  • Requires PHP >
Download this release

Release Info

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

Code changes from version 0.78.1 to 0.79

include/lcp-category.php CHANGED
@@ -58,15 +58,32 @@ class LcpCategory{
58
  return $lcp_category_id;
59
  }
60
 
61
- public function current_category(){
 
 
 
62
  $category = get_category( get_query_var( 'cat' ) );
63
  if( isset( $category->errors ) && $category->errors["invalid_term"][0] == __("Empty Term.") ){
64
  global $post;
65
- $categories = get_the_category($post->ID);
 
 
 
 
66
  if ( !empty($categories) ){
67
- return $categories[0]->cat_ID;
 
 
 
 
 
 
 
 
 
 
68
  } else {
69
- return;
70
  }
71
  }
72
  return $category->cat_ID;
58
  return $lcp_category_id;
59
  }
60
 
61
+ public function current_category($mode){
62
+ // Only single post pages with assigned category and
63
+ // category archives have a 'current category',
64
+ // in all other cases no posts should be returned. (#69)
65
  $category = get_category( get_query_var( 'cat' ) );
66
  if( isset( $category->errors ) && $category->errors["invalid_term"][0] == __("Empty Term.") ){
67
  global $post;
68
+ // Since WP 4.9 global $post is nullified in text widgets
69
+ // when is_singular() is false.
70
+ if (is_singular()) {
71
+ $categories = get_the_category($post->ID);
72
+ }
73
  if ( !empty($categories) ){
74
+ $cats = array_map(function($cat) {
75
+ return $cat->cat_ID;
76
+ }, $categories);
77
+ // AND relationship
78
+ if ('all' === $mode) return $cats;
79
+ // OR relationship, default
80
+ if ('yes' === $mode || '' === $mode) return implode(',', $cats);
81
+ // Exclude current categories
82
+ if ('other' === $mode) return implode(',', array_map(function($cat) {
83
+ return "-$cat";
84
+ }, $cats));
85
  } else {
86
+ return [0]; // workaround to display no posts
87
  }
88
  }
89
  return $category->cat_ID;
include/lcp-catlist.php CHANGED
@@ -134,10 +134,12 @@ class CatList{
134
  private function get_lcp_category(){
135
  // In a category page:
136
  if ( $this->utils->lcp_not_empty('categorypage') &&
137
- $this->params['categorypage'] == 'yes' ||
138
  $this->params['id'] == -1){
139
  // Use current category
140
- $this->lcp_category_id = LcpCategory::get_instance()->current_category();
 
 
141
  } elseif ( $this->utils->lcp_not_empty('name') ){
142
  // Using the category name:
143
  $this->lcp_category_id = LcpCategory::get_instance()->with_name( $this->params['name'] );
134
  private function get_lcp_category(){
135
  // In a category page:
136
  if ( $this->utils->lcp_not_empty('categorypage') &&
137
+ in_array($this->params['categorypage'], ['yes', 'all', 'other']) ||
138
  $this->params['id'] == -1){
139
  // Use current category
140
+ $this->lcp_category_id = LcpCategory::get_instance()->current_category(
141
+ $this->params['categorypage']
142
+ );
143
  } elseif ( $this->utils->lcp_not_empty('name') ){
144
  // Using the category name:
145
  $this->lcp_category_id = LcpCategory::get_instance()->with_name( $this->params['name'] );
include/lcp-catlistdisplayer.php CHANGED
@@ -107,6 +107,8 @@ class CatListDisplayer {
107
 
108
  $this->get_category_description();
109
 
 
 
110
  $this->lcp_output .= '<' . $tag;
111
 
112
  // Follow the numner of posts in an ordered list with pagination
@@ -127,8 +129,6 @@ class CatListDisplayer {
127
  $this->lcp_output .= '>';
128
  $inner_tag = ( ($tag == 'ul') || ($tag == 'ol') ) ? 'li' : 'p';
129
 
130
- $this->lcp_output .= $this->get_conditional_title();
131
-
132
  //Posts loop
133
  global $post;
134
  while ( have_posts() ) : the_post();
107
 
108
  $this->get_category_description();
109
 
110
+ $this->lcp_output .= $this->get_conditional_title();
111
+
112
  $this->lcp_output .= '<' . $tag;
113
 
114
  // Follow the numner of posts in an ordered list with pagination
129
  $this->lcp_output .= '>';
130
  $inner_tag = ( ($tag == 'ul') || ($tag == 'ol') ) ? 'li' : 'p';
131
 
 
 
132
  //Posts loop
133
  global $post;
134
  while ( have_posts() ) : the_post();
include/lcp-parameters.php CHANGED
@@ -140,14 +140,22 @@ class LcpParameters{
140
  }
141
 
142
  if ( $this->utils->lcp_not_empty('exclude_tags') ){
143
- $args = $this->lcp_excluded_tags($params);
144
  }
145
 
146
  // Current tags
147
- if ( $this->utils->lcp_not_empty('currenttags') && $params['currenttags'] == "yes" ){
 
148
  $tags = $this->lcp_get_current_tags();
149
- if ( !empty($tags) ){
150
- $args['tag__in'] = $tags;
 
 
 
 
 
 
 
151
  }
152
  }
153
 
@@ -279,7 +287,7 @@ class LcpParameters{
279
  }
280
 
281
  private function lcp_excluded_tags($args){
282
- $excluded_tags = explode(",", $args['exclude_tags']);
283
  $tag_ids = array();
284
  foreach ( $excluded_tags as $excluded){
285
  $tag_ids[] = get_term_by('slug', $excluded, 'post_tag')->term_id;
@@ -306,7 +314,7 @@ class LcpParameters{
306
  global $wpdb;
307
  $wp_posts_prefix = $wpdb->prefix . 'posts';
308
  $charset = $wpdb->get_col_charset($wp_posts_prefix, 'post_title');
309
-
310
  $where .= 'AND (' . $wp_posts_prefix . '.post_title ' .
311
  'COLLATE ' . strtoupper($charset) . '_GENERAL_CI LIKE \'' . $letters[0] . "%'";
312
  for ($i=1; $i <sizeof($letters); $i++) {
140
  }
141
 
142
  if ( $this->utils->lcp_not_empty('exclude_tags') ){
143
+ $args = $this->lcp_excluded_tags($args);
144
  }
145
 
146
  // Current tags
147
+ $currenttags = $params['currenttags'];
148
+ if ( $currenttags === 'yes' || $currenttags === 'all' ) {
149
  $tags = $this->lcp_get_current_tags();
150
+
151
+ if ( !empty($tags) ) {
152
+ // OR relationship
153
+ if ( 'yes' === $currenttags ) {
154
+ $args['tag__in'] = $tags;
155
+ } else {
156
+ // AND relationship
157
+ $args['tag__and'] = $tags;
158
+ }
159
  }
160
  }
161
 
287
  }
288
 
289
  private function lcp_excluded_tags($args){
290
+ $excluded_tags = explode(",", $this->params['exclude_tags']);
291
  $tag_ids = array();
292
  foreach ( $excluded_tags as $excluded){
293
  $tag_ids[] = get_term_by('slug', $excluded, 'post_tag')->term_id;
314
  global $wpdb;
315
  $wp_posts_prefix = $wpdb->prefix . 'posts';
316
  $charset = $wpdb->get_col_charset($wp_posts_prefix, 'post_title');
317
+
318
  $where .= 'AND (' . $wp_posts_prefix . '.post_title ' .
319
  'COLLATE ' . strtoupper($charset) . '_GENERAL_CI LIKE \'' . $letters[0] . "%'";
320
  for ($i=1; $i <sizeof($letters); $i++) {
include/lcp-utils.php CHANGED
@@ -22,6 +22,7 @@ class LcpUtils{
22
  "modified" => __("Modified Date", "list-category-posts"),
23
  "title" => __("Post title", "list-category-posts"),
24
  "author" => __("Author", "list-category-posts"),
 
25
  "rand" => __("Random", "list-category-posts"));
26
  }
27
 
@@ -36,4 +37,4 @@ class LcpUtils{
36
  ($pagination !== 'no')
37
  );
38
  }
39
- }
22
  "modified" => __("Modified Date", "list-category-posts"),
23
  "title" => __("Post title", "list-category-posts"),
24
  "author" => __("Author", "list-category-posts"),
25
+ "ID" => __("ID", "list-category-posts"),
26
  "rand" => __("Random", "list-category-posts"));
27
  }
28
 
37
  ($pagination !== 'no')
38
  );
39
  }
40
+ }
include/lcp-widget.php CHANGED
@@ -84,7 +84,8 @@ class ListCategoryPostsWidget extends WP_Widget{
84
 
85
  // Fetch the category id from the Catlist instance.
86
  $category_id = $catlist_displayer->catlist->get_category_id();
87
- if ($category_id === null && ($title == 'catlink' || $title == 'catname')) {
 
88
  $title = '';
89
  } elseif ($title == 'catlink') {
90
  // If the user has setup 'catlink' as the title, replace it with
84
 
85
  // Fetch the category id from the Catlist instance.
86
  $category_id = $catlist_displayer->catlist->get_category_id();
87
+ if ((is_null($category_id) || [0] === $category_id ) &&
88
+ ($title == 'catlink' || $title == 'catname')) {
89
  $title = '';
90
  } elseif ($title == 'catlink') {
91
  // If the user has setup 'catlink' as the title, replace it with
list-category-posts.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: List category posts
4
  Plugin URI: https://github.com/picandocodigo/List-Category-Posts
5
  Description: List Category Posts allows you to list posts by category in 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, the number of posts to display and many more parameters. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2].
6
- Version: 0.78.1
7
  Author: Fernando Briano
8
  Author URI: http://fernandobriano.com
9
 
3
  Plugin Name: List category posts
4
  Plugin URI: https://github.com/picandocodigo/List-Category-Posts
5
  Description: List Category Posts allows you to list posts by category in 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, the number of posts to display and many more parameters. You can use [catlist] as many times as needed with different arguments. Usage: [catlist argument1=value1 argument2=value2].
6
+ Version: 0.79
7
  Author: Fernando Briano
8
  Author URI: http://fernandobriano.com
9
 
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: fernandobt
3
  Donate Link: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/#support
4
  Tags: list, categories, posts, cms
5
  Requires at least: 3.3
6
- Tested up to: 4.9.7
7
- Requires PHP: 5.2.4
8
- Stable tag: 0.78.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -38,6 +38,11 @@ The different elements to display can be styled with CSS. you can define an HTML
38
 
39
  Great to use WordPress as a CMS, and create pages with several categories posts.
40
 
 
 
 
 
 
41
  **Widget**
42
 
43
  Since WordPress 4.9, [you can use shortcode in text widgets](https://make.wordpress.org/core/2017/10/24/widget-improvements-in-wordpress-4-9/). So you can just add a text widget in Appearence > Widgets and write the List Category Posts shortcode.
@@ -65,294 +70,59 @@ Since the documentation on how to use the plugin has passed wordpress.org's char
65
 
66
  ==Instructions on how to use the plugin==
67
 
68
- ==SELECTING THE CATEGORY==
69
- The plugin can figure out the category from which you want to list posts in several ways. **You should use only one of these methods** since these are all mutually exclusive, weird results are expected when using more than one:
70
-
71
- * Using the *category id*.
72
- * **id** - To display posts from a category using the category's id. Ex: `[catlist id=24]`.
73
- * The *category name or slug*.
74
- * **name** - To display posts from a category using the category's name or slug. Ex: `[catlist name=mycategory]`
75
- * *Detecting the current post's category*. You can use the *categorypage* parameter to make it detect the category id of the current post, and list posts from that category.
76
- * **categorypage** - Set it to "yes" if you want to list the posts from the current post's category. `[catlist categorypage="yes"]`
77
-
78
- When using List Category Posts whithout a category id, name or slug, it will post the latest posts from **every category**.
79
-
80
- ==USING MORE THAN ONE CATEGORY==
81
-
82
- * Posts from several categories with an **AND** relationship, posts that belong to all of the listed categories (note this does not show posts from any children of these categories): `[catlist id=17+25+2]` - `[catlist name=sega+nintendo]`.
83
- * Posts from several categories with an **OR** relationship, posts that belong to any of the listed categories: `[catlist id=17,24,32]` - `[catlist name=sega,nintendo]`.
84
- * **Exclude** a category with the minus sign (-): `[catlist id=11,-32,16]`, `[catlist id=1+2-3]`. **Important**: When using the *and* relationship, you should write the categories you want to include first, and then the ones you want to exclude. So `[catlist id=1+2-3]` will work, but `[catlist id=1+2-3+4]` won't.
85
-
86
- ==Other ways of selecting what posts to show==
87
-
88
- * **child_categories** - Exclude/include posts from the child categories. By default they are included. If you have a "Parent Category" and you use: `[catlist name="Parent Category"]`, you'll see posts from it's child categories as if they were posts from the same category. You can use this parameter to exclude these posts: `[catlist name="Parent Category" child_categories=false]`.
89
-
90
- * **author_posts** - Get posts by author. Use 'user_nicename' (NOT
91
- name). Example: `[catlist author_posts="fernando"]`
92
-
93
- * **tags** - Tag support, display posts from a certain tag. You can use an "OR" relationship `[catlist tags="nintendo,sega"]` or "AND" relationship (posts that belong to all of the listed tags): `[catilst tags="nintendo+sega"]`.
94
-
95
- * **taxonomy** - You can select posts using custom taxonomies. There's two ways of selecting taxonomies:
96
- * You need to set the taxonomy and the terms: `[catlist taxonomy='person' terms='bob']`. It supports both the "IN" and "AND" logical relationships between each inner taxonomy. For the `AND` relationship, separate terms with a plus sign: ` [catlist taxonomy='topic' terms='topic1+topic2']`. For the `OR` relationship, separate terms with a comma: `[catlist taxonomy='topic' terms='topic1,topic2']`.
97
- * Multiple taxonomies: You can use multiple taxonomy terms in one shortcode like this:
98
- * OR - `taxonomies_or="tax1:{term1_1,term1_2};tax2:{term2_1,term2_2,term2_3}"`
99
- * AND - `taxonomies_and="tax1:{term1_1,term1_2};tax2:{term2_1,term2_2,term2_3}"`
100
-
101
-
102
- * **currenttags** - Display posts from the current post's tags (won't
103
- work on pages since they have no tags). Pass it the 'yes' string for it to work: `[catlist currenttags="yes"]`
104
-
105
- * **exclude_tags** - Exclude posts from one or more tags: `[catlist tags="videogames" exclude_tags="sega,sony"]`
106
-
107
- * **starting_with** - Get posts whose title starts with a certain
108
- letter. Example: `[catlist starting_with="l"]` will list all posts
109
- whose title starts with L. You can use several letters: `[catlist starting_with="m,o,t"]`.
110
-
111
- * **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 monthnum=12]` will list posts from December 2012.
112
-
113
- * **date ranges** - You can also use date ranges for listing posts. For example "list every post after March 14th, 2005". The parameters are: ```after, after_year, after_month, after_day, before, before_year, before_month, before_day```. You can use `today` as a value, the plugin will get today's date dynamically and display only old posts. These parameters are used to specify data_query arguments (see: [the codex](https://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters)).
114
-
115
- If you want to list all the posts before a given date, say `Jun 17th, 2007` you can use these two options:
116
- `[catlist before_year=2007 before_month=06 before_day=17]`
117
- Or you can use the `before` parameter with a [strtotime()-compatible string](http://php.net/manual/en/datetime.formats.date.php):
118
- `[catlist before='2007/06/17']`
119
-
120
- The same works for posts after a given date, you can use:
121
- `[catlist after_year=2007 after_month=06 after_day=17]`
122
- Or just `after` with a [strtotime()-compatible string](http://php.net/manual/en/datetime.formats.date.php):
123
- `[catlist after='2007/06/17']`
124
-
125
- `after` takes priority over `after_year`, `after_month`, and `after_day`.
126
- `before` takes priority over `before_year`, `before_month`, and `before_day`.
127
-
128
- * **search** - List posts that match a search term. `[catlist search="The Cake is a lie"]`
129
-
130
- * **excludeposts** - IDs of posts to exclude from the list. Use 'this' to exclude the current post. Ex: `[catlist excludeposts=this,12,52,37]`
131
-
132
- * **offset** - You can displace or pass over one or more initial posts which would normally be collected by your query through the use of the offset parameter.
133
-
134
- * **post_type** - The type of post to show. Available options are: post - Default, page, attachment, any - all post types. You can use several types, example: `[catlist post_type="page,post" numberposts=-1]`
135
-
136
- * **post_status** - use post status, default value is 'publish'. Valid values:
137
- * **publish** - a published post or page.
138
- * **pending** - post is pending review.
139
- * **draft** - a post in draft status.
140
- * **auto-draft** - a newly created post, with no content.
141
- * **future** - a post to publish in the future.
142
- * **private** - not visible to users who are not logged in.
143
- * **inherit** - a revision. see get_children.
144
- * **trash** - post is in trashbin (available with Version 2.9).
145
- * **any** - retrieves any status except those from post types with 'exclude_from_search' set to true.
146
- You can use several post statuses. Example: `[catlist post_status="future, publish" excludeposts=this]`
147
-
148
- * **show_protected** - Show posts protected by password. By default
149
- they are not displayed. Use: `[catlist show_protected=yes]`
150
-
151
- * **post_parent** - Show only the children of the post with this ID.
152
- Default: None.
153
-
154
- * **custom fields** - To use custom fields, you must specify two values: customfield_name and customfield_value. `customfield_name` defines the name of the field, and you should choose the values for which you want posts to display. Using this only show posts that contain a custom field with this name and value. Both parameters must be defined, or neither will work. Eg: `[catlist customfield_name="color" customfield_value="green"]` will display posts with the value `green` set on the custom field `color`. This parameter can be used together with `customfield_orderby`, see further below for more information.
155
-
156
- ==PAGINATION
157
-
158
- See the wiki: [Pagination](https://github.com/picandocodigo/List-Category-Posts/wiki/Pagination).
159
-
160
- ==OTHER PARAMETERS==
161
-
162
- * **conditional_title** - Display a custom title before the posts list.
163
- The title is not displayed if the list is empty. Set to the empty string
164
- (default value) to disable.
165
- Example: `[catlist conditional_title="Other posts"]`.
166
-
167
- * **conditional_title_tag** - Specify the tag used for the conditional title.
168
- Defaults to 'h3'.
169
-
170
- * **conditional_title_class** - Specify the class used for the conditional
171
- title. Defaults to the empty string (no special class).
172
-
173
- * **orderby** - To customize the order. Valid values are:
174
- * **author** - Sort by the numeric author IDs.
175
- * **category** - Sort by the numeric category IDs.
176
- * **content** - Sort by content.
177
- * **date** - Sort by creation date.
178
- * **ID** - Sort by numeric post ID.
179
- * **menu_order** - Sort by the menu order. Only useful with pages.
180
- * **mime_type** - Sort by MIME type. Only useful with attachments.
181
- * **modified** - Sort by last modified date.
182
- * **name** - Sort by stub.
183
- * **parent** - Sort by parent ID.
184
- * **password** - Sort by password.
185
- * **rand** - Randomly sort results.
186
- * **status** - Sort by status.
187
- * **title** - Sort by title.
188
- * **type** - Sort by type. Ex: `[catlist name=mycategory orderby=date]`
189
-
190
- * **customfield_orderby** - You can order the posts by a custom field. For example: `[catlist numberposts=-1 customfield_orderby=Mood order=desc]` will list all the posts with a "Mood" custom field. This parameter can be used toghether with `customfield_name` and `customfield_value`, you can use those parameters to select posts and then `customfield_orderby` to sort by this or another custom field. Remember the default order is descending, more on order:
191
-
192
- * **order** - How to sort **orderby**. Valid values are:
193
- * **ASC** - Ascending (lowest to highest).
194
- * **DESC** - Descending (highest to lowest). Ex: `[catlist name=mycategory orderby=title order=asc]`
195
 
196
- * **numberposts** - Number of posts to return. Set to 0 to use the max
197
- number of posts per page. Set to -1 to remove the limit.
198
- Ex: `[catlist name=mycategory numberposts=10]`
199
- You can set the default number of posts globally on the options
200
- page on your Dashboard in Settings / List Category Posts.
201
 
202
- * **no_posts_text** - Text to display when no posts are found. If you
203
- don't specify it, nothing will get displayed where the posts
204
- should be.
205
 
206
- * **date** - Display post's date next to the title. Default is 'no',
207
- use date=yes to activate it. You can set a css class and an html
208
- tag to wrap the date in with `date_class` and `date_tag` (see HTML
209
- & CSS Customization further below).
210
 
211
- * **date_modified** - Display the date a post was last modified next
212
- to the title. You can set a css class and an html tag to wrap the
213
- date in with `date_modified_class` and `date_modified_tag` (see
214
- HTML & CSS Customization further below).
215
 
216
- * **author** - Display the post's author next to the title. Default is
217
- 'no', use author=yes to activate it. You can set a css class and an html
218
- tag to wrap the author name in with `author_class` and `author_tag` (see HTML
219
- & CSS Customization further below).
220
 
221
- When displaying the post author, you can also display a link to the
222
- author's page. The following parameter **only works if author=yes
223
- is present in the shortcode**:
224
 
225
- * **author_posts_link** - Gets the URL of the author page for the
226
- author. The HTML and CSS customization are the ones applied to `author`.
 
 
227
 
228
- * **dateformat** - Format of the date output. The default format is the one you've set on your WordPress settings. Example: `[catlist id=42 dateformat="l F dS, Y"]` would display the date as "Monday January 21st, 2013". Check http://codex.wordpress.org/Formatting_Date_and_Time for more options to display date.
 
 
229
 
230
- * **excerpt** - Display a plain text excerpt of the post. Default is 'no', use `excerpt=yes` or `excerpt=full` to activate it. If you have a separate excerpt in your post, this text will be used. If you don't have an explicit excerpt in your post, the plugin will generate one from the content, striping its images, shortcodes and HTML tags. If you want to overwrite the post's separate excerpt with an automatically generated one (may be useful to allow HTML tags), use `excerpt_overwrite=yes`.
 
 
 
231
 
232
- If you use `excerpt=yes`, the separate excerpt or content will be limited to the number of words set by the *excerpt_size* parameter (55 words by default).
 
233
 
234
- If you use `excerpt=full` the plugin will act more like Wordpress. If the post has a separate excerpt, it will be used in full. Otherwise if the content has a &lt;!--more--&gt; tag then the excerpt will be the text before this tag, and if there is no &lt;!--more--&gt; tag then the result will be the same as `excerpt=yes`.
 
235
 
236
- If you want the automatically generated excerpt to respect your theme's allowed HTML tags, you should use `excerpt_strip=no`, otherwise the HTML tags are automatically stripped.
 
 
237
 
238
- * **excerpt_size** - Set the number of *words* to display from the excerpt. Default is 55. Eg: `excerpt_size=30`
 
 
239
 
240
- * **excerpt_strip** - Set it to `yes` to strip the excerpt's HTML tags. If the excerpt is auto generated by the plugin, the HTML tags will be stripped, and you should use `excerpt_strip=no` to see the excerpt with HTML formatting.
 
 
241
 
242
- * **title_limit** - Set the limit of characters for the title. Ex:
243
- `[catlist id=2 title_limit=50]` will show only the first 50
244
- characters of the title and add "…" at the end.
245
-
246
- * **content** - **WARNING**: If you want to show the content on your listed posts, you might want to do this from a new [Page Template](http://codex.wordpress.org/Page_Templates) or a [Custom Post Type](http://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates) template. Using this parameter is discouraged, you can have memory issues as well as infinite loop situations when you're displaying a post that's using List Category Posts. You have been warned. Usage:
247
-
248
- * `yes` - Show the excerpt or full content of the post. If there's a &lt;!--more--&gt; tag in the post, then it will behave just as WordPress does: only show the content previous to the more tag. Default is 'no'. Ex: `[catlist content=yes]`
249
-
250
- * `full` - Show the full content of the post regardless of whether there is a &lt;!--more--&gt; tag in the post. Ex: `[catlist content=full]`
251
-
252
- * **catlink** - Show the title of the category with a link to the category. Use the **catlink_string** option to change the link text. Default is 'no'. Ex: `[catlist catlink=yes]`. The way it's programmed, it should only display the title for the first category you chose, and include the posts from all of the categories. I thought of this parameter mostly for using several shortcodes on one page or post, so that each group of posts would have the title of that group's category. If you need to display several titles with posts, you should use one [catlist] shortcode for each category you want to display.
253
-
254
- * **category_description** Show the category description wrapped in a p tag: `[catlist id=1 category_description='yes']`
255
-
256
- * **catname** - Show the title of the category (or categories), works exactly as `catlink`, but it doesn't add a link to the category.
257
-
258
- * **category_count** - Shows the posts count in that category, only works when using the **catlink** option: `[catlist name=nintendo catlink=yes category_count=yes]`
259
-
260
- * **comments** - Show comments count for each post. Default is 'no'. Ex: `[catlist comments=yes]`.
261
-
262
- * **thumbnail** - Show post thumbnail (http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/). Default is 'no'. Ex: `[catlist thumbnail=yes]`.
263
-
264
- * **force_thumbnail** - If the previous parameter is set to 'yes', and there's no featured image, setting this to 'yes' or 'true' will make the plugin look for the first image in the post and use it as a thumbnail. Ex: `[catlist thumbnail=yes force_thumbnail=yes]`.
265
-
266
- * **thumbnail_size** - Either a string keyword (thumbnail, medium, large or full) or 2 values representing width and height in pixels. Ex: `[catlist thumbnail_size=32,32]` or `[catlist thumbnail_size=thumbnail]`
267
-
268
- * **thumbnail_class** - Set a CSS class for the thumbnail.
269
-
270
- * **post_suffix** - Pass a String to this parameter to display this
271
- String after every post title.
272
- Ex: `[catlist numberposts=-1
273
- post_suffix="Hello World"]` will create something like:
274
-
275
- `<ul class="lcp_catlist" id=lcp_instance_0>`
276
- ` <li>`
277
- ` <a href="http://127.0.0.1:8080/wordpress/?p=42" title="WordPress">`
278
- ` WordPress`
279
- ` </a> Hello World </li>`
280
-
281
- * **display_id** - Set it to yes to show the Post's ID next to the post title: `[catlist id=3 display_id=yes]`
282
-
283
- * **class** - CSS class for the default UL generated by the plugin.
284
-
285
- * **tags_as_class** - Use a post's tags as a class for the `li` that lists the posts. Default is `no`. For example, `[catlist tags_as_class=yes]` will show a post that has the `fun` tag like this:
286
- ```
287
- <li class=" fun ">
288
- <a href="http://localhost:8080/?p=1267" title="Post Title">Post Title</a>
289
- </li>
290
- ```
291
-
292
- * **customfield_display** - Display custom field(s). You can specify
293
- many fields to show, separating them with a coma. If you want to
294
- display just the value and not the name of the custom field, use
295
- `customfield_display_name` and set it to no.
296
- By default, the custom fields will show inside a div with a
297
- specific class: `<div class="lcp-customfield">`. You can customize
298
- this using the customfield_tag and customfield_class parameters to
299
- set a different tag (instead of the div) and a specific class
300
- (instead of lcp-customfield).
301
-
302
- * **customfield_display_glue** - Specify the text to appear between two custom
303
- fields if displayed together, defaults to the empty string. Not used if
304
- the `customfield_display_separately` parameter is defined.
305
-
306
- * **customfield_display_separately** - Display the custom fields separately.
307
- Each custom field is displayd within its own tag (see `customfield_tag`).
308
- Defaults to 'no', set to 'yes' to enable. Superseeds the
309
- `customfield_display_glue` parameter when enabled.
310
-
311
- * **customfield_display_name** - To use with `customfield_display`.
312
- Use it to just print the value of the Custom field and not the
313
- name. Example:
314
- `[catlist numberposts=-1 customfield_display="Mood"
315
- customfield_display_name="no"]`
316
- Will print the value of the Custom Field "Mood" but not the text
317
- "Mood: [value]".
318
-
319
- * **customfield_display_name_glue** - To use with `customfield_display_name`.
320
- Use it to specify the text between the name and the value, defaults to
321
- ' : '.
322
-
323
- * **template** - By default, posts will be listed in an unordered list
324
- (ul tag) with the class 'lcp_catlist':
325
-
326
- `<ul class="lcp_catlist"><li><a href="post1">Post 1</a></li>...`
327
-
328
- You can use a different class by using the *class* parameter.
329
-
330
- You can create your own template file (Check **Template System**
331
- further down this document) and pass it as a parameter here. The
332
- parameter is the template name without the extension. For example
333
- for `mytemplate.php`, the value would be `mytemplate`.
334
-
335
- You can also pass these two parameters which yield different
336
- results:
337
- * `div` - This will output a div with the `lcp_catlist` class
338
- (or one you pass as a parameter with the `class` argument). The
339
- posts will be displayed between p tags. `[catlist template=div]`
340
-
341
- * `ol` - This will output an ordered list with the `lcp_catlist`
342
- css class (or the one you pass as a parameter with the `class`
343
- argument) and each post will be a list item inside the ordered list. `[catlist template=ol]`.
344
-
345
- * **morelink** - Include a "more" link to access the category archive for the category. The link is inserted after listing the posts. It receives a string of characters as a parameter which will be used as the text of the link. Example: `[catlist id=38 morelink="Read more"]`
346
-
347
- * **posts_morelink** - Include a "read more" link after each post. It receives a string of characters as a parameter which will be used as the text of the link. Example: `[catlist id=38 posts_morelink="Read more about this post"]`
348
-
349
- * **link_target** - Select the `target` attribute for links to posts (target=_blank, _self, _parent, _top, *framename*). Example: `[catlink id=3 link_target=_blank]` will create: `<a href="http://localhost/wordpress/?p=45" title="Test post" target="_blank">Test post</a>`
350
-
351
- * **no_post_titles** - If set to `yes`, no post titles will be shown. This may make sense together with `content=yes`.
352
-
353
- * **link_titles** - Option to display titles without links. If set to `false`, the post titles won't be linking to the article.
354
-
355
- * **link_dates** - Option to wrap dates with a link to the post. Set to `true` or `yes` to enable, set to `false` or `no` to disable. Defaults to `false`.
356
 
357
 
358
  ==Installation==
@@ -440,6 +210,17 @@ Template system has changed. Custom templates should be stored in WordPress them
440
 
441
  == Changelog ==
442
 
 
 
 
 
 
 
 
 
 
 
 
443
  = 0.78.1 =
444
 
445
  * Refactor in widget parameters by @zymeth25, all widget related issues with missing parameters will be gone for good.
3
  Donate Link: http://picandocodigo.net/programacion/wordpress/list-category-posts-wordpress-plugin-english/#support
4
  Tags: list, categories, posts, cms
5
  Requires at least: 3.3
6
+ Tested up to: 5.0
7
+ Requires PHP: 5.4
8
+ Stable tag: 0.79
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
38
 
39
  Great to use WordPress as a CMS, and create pages with several categories posts.
40
 
41
+ **GUI**
42
+
43
+ Klemens Starybrat has created a GUI for List Category Posts. It helps you create a shortcode from a nice visual interface in WordPress' text editor. Check it out:
44
+ [GUI for List Category Posts](https://wordpress.org/plugins/gui-for-lcp/)
45
+
46
  **Widget**
47
 
48
  Since WordPress 4.9, [you can use shortcode in text widgets](https://make.wordpress.org/core/2017/10/24/widget-improvements-in-wordpress-4-9/). So you can just add a text widget in Appearence > Widgets and write the List Category Posts shortcode.
70
 
71
  ==Instructions on how to use the plugin==
72
 
73
+ Below you can find common shortcode use cases. You can use the shortcode while editing posts, pages, custom post types, text widgets and in all "page builder" plugins that support shortcodes.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
+ Read the **[full documentation](https://github.com/picandocodigo/List-Category-Posts/wiki)** to discover many more features, including:
 
 
 
 
76
 
77
+ * **advanced post selection options** (by date, search terms, custom fields, post types, custom taxonomies and more)
78
+ * **output customizations** (show each post's date, author, excerpt, thumbnail and more)
79
+ * **custom templates** of your own design, based on a simple PHP example
80
 
81
+ List 10 latest posts:
82
+ `[catlist]`
 
 
83
 
84
+ The default number of listed posts is 10, to modify it you need to specify `numberposts` parameter:
85
+ `[catlist numberposts=15]`
 
 
86
 
87
+ List posts from the "Dogs" category:
88
+ `[catlist name=Dogs]`
 
 
89
 
90
+ List posts from the category with id `2`:
91
+ `[catlist id=2]`
 
92
 
93
+ By default only the "post" post type is included. To list pages use:
94
+ `[catlist post_type=page]`
95
+ and for both posts and pages:
96
+ `[catlist post_type="post,page"]`
97
 
98
+ If we combine the above options we can get a shortcode that lists 15 items, including post and pages, from the "Dogs" category:
99
+ `[catlist name=Dogs post_type="post,page" numberposts=15]`
100
+ Most of the parameters you will find in the documentation can be used together.
101
 
102
+ The plugin can detect current post's category and use it for listing:
103
+ `[catlist categorypage=yes]`
104
+ Same goes for tags:
105
+ `[catlist currenttags=yes]`
106
 
107
+ To show each post's excerpt use:
108
+ `[catlist excerpt=yes]`
109
 
110
+ If you want to show the date, author and comments count next to each post, use:
111
+ `[catlist date=yes author=yes comments=yes]`
112
 
113
+ You can specify html tags and classes for many elements. Let's modify the previous shortcode and wrap dates and authors in tags and classes of our choice:
114
+ `[catlist date=yes date_tag=span date_class="my-date" author=yes author_tag=p author_class="my-author" comments=yes]`
115
+ [Read more about this feature](https://github.com/picandocodigo/List-Category-Posts/wiki/HTML-&-CSS-Customization)
116
 
117
+ You can order posts by date:
118
+ `[catlist orderby=date]`
119
+ You can also use `title`, `author`, `ID`. More options are described in the documentation.
120
 
121
+ The plugin also supports pagination. You need to specify `numberposts` to tell the plugin how many posts per page you want:
122
+ `[catlist pagination=yes numberposts=5]`
123
+ See the wiki: [Pagination](https://github.com/picandocodigo/List-Category-Posts/wiki/Pagination) for more information.
124
 
125
+ Please read the **[full documentation](https://github.com/picandocodigo/List-Category-Posts/wiki)** for detailed documentation of all plugin features, use cases and shortcode parameters.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
 
128
  ==Installation==
210
 
211
  == Changelog ==
212
 
213
+ = 0.79 =
214
+
215
+ * Requires PHP >= 5.4
216
+ * `categorypage` now suppports `yes` for all post's categories with OR relationship, `all` for AND relationship and `other` to get all categories except current categories (with OR relationship) (thanks @zymeth25! 🎉)
217
+ * Possibly one of the last versions before 1.0.
218
+ * Fixes in current category (thanks @zymeth25! 🎉)
219
+ * Added link to Klemens' GUI.
220
+ * Moved documentation to the wiki: https://github.com/picandocodigo/List-Category-Posts/wiki
221
+ * Add 'id' to widget ordering options (thanks @zymeth25! 🎉)
222
+ * Add currenttags=all for AND relationship (thanks @zymeth25! 🎉)
223
+
224
  = 0.78.1 =
225
 
226
  * Refactor in widget parameters by @zymeth25, all widget related issues with missing parameters will be gone for good.