JoeHana
5/15/2015 - 1:21 PM

wpCasa: Order listing by price (DESC) by default on property/listing category pages

wpCasa: Order listing by price (DESC) by default on property/listing category pages

<?php

/**
 * Order listing by price (DESC) by default on property/listing category pages
 */

add_filter( 'wpsight_listing_taxonomy_query_args', 'custom_listing_query_args' );

function custom_listing_query_args( $args ) {

    if( isset( $_GET['order'] ) || isset( $_GET['order'] ) )
        return $args;

    if( is_tax( 'property-category' ) || is_tax( 'listing-category' ) ) {
        $args['order']      = 'ASC';
        $args['orderby']    = 'meta_value_num';
        $args['meta_key']   = '_price';
    }

    return $args;

}