jmchasco
Forum Replies Created
-
Forum: Plugins
In reply to: [Post List] Feature request – Arrange by nameHi there,
It’s easy to make that modification,In the file postlist.php inside the plugin’s folder, make the following modifications:
Line 19, After'requesttype' => '0',
Add two new lines
'orderby' => 'date', 'order' => 'DESC'
Line 39, Replace
$query->query("category_name=$cat&tag=$tag&showposts=$number");
by
$query->query("category_name=$cat&tag=$tag&showposts=$number&order=$order&orderby=$orderby");
Then you can use the shortcode as follow:
[postlist cat=”YOURCATHERE” orderby=”title” order=”DESC”]The new two parameters can take any of these values:
order (string) – Designates the ascending or descending order of the ‘orderby’ parameter. Defaults to ‘DESC’.
‘ASC’ – ascending order from lowest to highest values (1, 2, 3; a, b, c).
‘DESC’ – descending order from highest to lowest values (3, 2, 1; c, b, a).orderby (string) – Sort retrieved posts by parameter. Defaults to ‘date’.
‘none’ – No order (available with Version 2.8).
‘ID’ – Order by post id. Note the captialization.
‘author’ – Order by author.
‘title’ – Order by title.
‘name’ – Order by post name (post slug).
‘date’ – Order by date.
‘modified’ – Order by last modified date.
‘parent’ – Order by post/page parent id.
‘rand’ – Random order.
‘comment_count’ – Order by number of comments (available with Version 2.9).
‘menu_order’ – Order by Page Order. Used most often for Pages (Order field in the Edit Page Attributes box) and for Attachments (the integer fields in the Insert / Upload Media Gallery dialog), but could be used for any post type with distinct ‘menu_order’ values (they all default to 0).
‘meta_value’ – Note that a ‘meta_key=keyname’ must also be present in the query. Note also that the sorting will be alphabetical which is fine for strings (i.e. words), but can be unexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as you might naturally expect). Use ‘meta_value_num’ instead for numeric values.
‘meta_value_num’ – Order by numeric meta value (available with Version 2.8). Also note that a ‘meta_key=keyname’ must also be present in the query. This value allows for numerical sorting as noted above in ‘meta_value’.
‘post__in’ – Preserve post ID order given in the post__in array (available with Version 3.5).As you can see here https://codex.www.ads-software.com/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
Cheers.
Yes, it is v. 0.3.b5
Keep it going !! you are doing a nice work with this plugin !!
Let us know if you plan to include my [post_thumb] fix in next release, so i could update the plugin without repatch the code. !!
By the way, in next days i will try to work in a new filter for the plugin, posts [prior|late] to a publishing date, or between a range. !! we will see.
Cheers !!
Hi there,
I patched some code to solve this, and allow the use of thumbnail, medium, large or original image size.In wp-content/plugins/advanced-post-list/includes/class/APLCore.php
At Line 2363
Replace$arr = wp_get_attachment_image_src(get_post_thumbnail_id($page->ID), 'thumbnail'); $str = str_replace("[post_thumb]",$arr[0], $str);
by
$str = preg_replace_callback('#\[ *post_thumb *(size=[\'|\"]([^\'\"]*)[\'|\"])? *\]#', array(&$postCallback, 'postThumbnailCallback'), $str);
In wp-content/plugins/advanced-post-list/includes/class/APLCallback.php
Add the callback function:function postThumbnailCallback($matches){ $arr = wp_get_attachment_image_src(get_post_thumbnail_id($this->page->ID),$matches[2]); return($arr[0]); }
Then, the shortcode for [post_thumb] can be used as [post_thumb size=”thumbnail”]
medium and large values can also be specified, if size is empty or size parameter is not present original file will be returned.Thanks a lot for your useful plugin !