WordPress.org

Ready to get started?Download WordPress

Forums

Post List
Feature request - Arrange by name (2 posts)

  1. Jeffrey Driver
    Member
    Posted 1 year ago #

    Hi,

    Love this plugin for its simplicity, but it would be great if it was possible to display the list by name, either ascending or descending. Is it not possible with the current version?

    http://wordpress.org/extend/plugins/post-list/

  2. jmchasco
    Member
    Posted 1 year ago #

    Hi 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 http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

    Cheers.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.