johnbillion / extended-cpts

A library which provides extended functionality to WordPress custom post types and taxonomies.
GNU General Public License v2.0
979 stars 96 forks source link

support orderby meta_value_* #55

Closed salkhwlani closed 7 years ago

salkhwlani commented 8 years ago

add support pass orderby meta_value_* in site_sortables & admin_cols

'site_sortables' => array(
    'meta_name' => array(
        'meta_key' => 'meta_name',
        'orderby' => 'meta_value_num',
        'default' => 'desc',
    )
),

'admin_cols' => array(
    // A meta field column:
    'meta_name' => array(
        'title'    => 'meta title',
        'meta_key' => 'meta_name',
        'orderby' => 'meta_value_num',
        'default' => 'desc',
    ),
),

for more information about meta_value_* look section “Order & Orderby Parameters

johnbillion commented 7 years ago

Thanks for the patch, but this means clicking on the column header could potentially not sort by that field, which is not what any user would expect. The purpose of clicking a column header is to sort by the values show in the column.