[wp-trac] [WordPress Trac] #25493: Sorting posts in ascending order of date at admin side

WordPress Trac noreply at wordpress.org
Wed Nov 11 02:03:35 UTC 2015


#25493: Sorting posts in ascending order of date at admin side
-------------------------------------+-----------------------------
 Reporter:  vinod dalvi              |       Owner:  wonderboymusic
     Type:  defect (bug)             |      Status:  closed
 Priority:  normal                   |   Milestone:  4.4
Component:  Posts, Post Types        |     Version:  3.1
 Severity:  normal                   |  Resolution:  fixed
 Keywords:  has-patch needs-refresh  |     Focuses:  administration
-------------------------------------+-----------------------------

Comment (by cklosows):

 The addition of the `get_orderby` and `get_order` methods in `class-wp-
 posts-list-table.php` seems to have caused the sorting of custom columns
 for a custom post type fail when using the filter method, instead of
 extending the `WP_List_Table` class.

 In the main `class-wp-list-table.php` these methods pull from `$_GET`

 {{{
         /**
          * If 'orderby' is set, return it.
          *
          * @access protected
          * @since 4.4.0
          *
          * @return string The value of 'orderby' or empty string.
          */
         protected function get_orderby() {
                 if ( isset( $_GET['orderby'] ) ) {
                         return $_GET['orderby'];
                 }

                 return '';
         }

         /**
          * If 'order' is 'desc', return it. Else return 'asc'.
          *
          * @access protected
          * @since 4.4.0
          *
          * @return string 'desc' or 'asc'.
          */
         protected function get_order() {
                 if ( isset( $_GET['order'] ) && 'desc' === $_GET['order']
 ) {
                         return 'desc';
                 }

                 return 'asc';
         }
 }}}


 However in `class-wp-posts-list-table.php` they are relying on the
 `get_query_var()` function, which in order to do a meta query sort,
 requires setting the `orderby` to `meta_value` or `meta_value_num`.

 Am I missing something in this case? Here is a link to the implementation
 used in the Easy Digital Downloads core:
 https://github.com/easydigitaldownloads/Easy-Digital-
 Downloads/blob/master/includes/admin/downloads/dashboard-columns.php#L115

--
Ticket URL: <https://core.trac.wordpress.org/ticket/25493#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list