WP职位经理 - Orderby Customfield

I'm using the plugin WP Job Manager, and have a custom field with the meta_key = rating.

I want to be able to order listings by rating and via the short code "orderby".

Normally for posts I imagine it would be something like this in funcitons.php:

$args = array(
    'orderby'  => 'meta_value',
    'meta_key' => 'rating',
    'meta_query' => array(
        array(
            'key'     => 'rating',
            'value'   => null,
            'compare' => '!=' 
        )

    ), // End of meta_query
    'fields'  => 'ID',
    'exclude' => array(
        1
    ),

);

Anyone who knows how to do this?

Try adding this to functions.php:

function args_function_rating_dsaw($args) {
    $args['orderby'] = 'meta_value_num';
    $args['order'] = 'DESC';
    $args['meta_key'] = 'rating';
    return $args;
}

i just found solution its late but maybe some one will use it :) i as do

function set_custom_post_types_admin_order($wp_query) {
$post_type = $wp_query->query['post_type']; // line 105
    if ( $post_type == 'job_listing') {
      $wp_query->set('orderby', '_v_power');
      $wp_query->set('order', 'ASC');
    }
}
add_filter('pre_get_posts', 'set_custom_post_types_admin_order');