Hi,
I need sorting of title alphabetically done for the list on http://tours.stayinchiangmai.com/tour/, currently I have added the component, but stuck of what function for sorting should I apply here.
Below is the component php
<div class="col-md-3 col-sm-3 col-xs-6">
<div class="styled-select-filters">
<select name="sort_title" id="sort_title" data-base-url="<?php echo esc_url( remove_query_arg( array( 'order', 'order_by', 'page' ) ) ); ?>">
<option value="" <?php if ( $order_by != 'title' ) echo 'selected' ?>><?php echo esc_html__( 'Sort by title', 'citytours' ) ?></option>
<option value="lower" <?php if ( $order_by == 'title' && $order == 'ASC' ) echo 'selected' ?>><?php echo esc_html__( 'Title Ascending', 'citytours' ) ?></option>
<option value="higher" <?php if ( $order_by == 'title' && $order == 'DESC' ) echo 'selected' ?>><?php echo esc_html__( 'Title Descending', 'citytours' ) ?></option>
</select>
</div></div>
<div class="col-md-3 col-sm-3 col-xs-6">
<div class="styled-select-filters">
<select name="sort_price" id="sort_price" data-base-url="<?php echo esc_url( remove_query_arg( array( 'order', 'order_by', 'page' ) ) ); ?>">
<option value="" <?php if ( $order_by != 'price' ) echo 'selected' ?>><?php echo esc_html__( 'Sort by price', 'citytours' ) ?></option>
<option value="lower" <?php if ( $order_by == 'price' && $order == 'ASC' ) echo 'selected' ?>><?php echo esc_html__( 'Lowest price', 'citytours' ) ?></option>
<option value="higher" <?php if ( $order_by == 'price' && $order == 'DESC' ) echo 'selected' ?>><?php echo esc_html__( 'Highest price', 'citytours' ) ?></option>
</select>
</div>
</div>
<div class="col-md-3 col-sm-3 col-xs-6">
<div class="styled-select-filters">
<select name="sort_rating" id="sort_rating" data-base-url="<?php echo esc_url( remove_query_arg( array( 'order', 'order_by', 'page' ) ) ); ?>">
<option value="" <?php if ( $order_by != 'rating' ) echo 'selected' ?>><?php echo esc_html__( 'Sort by rating', 'citytours' ) ?></option>
<option value="lower" <?php if ( $order_by == 'rating' && $order == 'ASC' ) echo 'selected' ?>><?php echo esc_html__( 'Lowest rating', 'citytours' ) ?></option>
<option value="higher" <?php if ( $order_by == 'rating' && $order == 'DESC' ) echo 'selected' ?>><?php echo esc_html__( 'Highest rating', 'citytours' ) ?></option>
</select></div></div>
Below are the functions for price and rating
$('#sort_price').change( function() {
var base_url = $(this).data('base-url').replace(/&/g, '&');
if ( $(this).val() == "lower" ) {
base_url += '&order_by=price&order=ASC';
} else if ( $(this).val() == "higher" ) {
base_url += '&order_by=price&order=DESC';
}
if (base_url.indexOf("?") < 0) { base_url = base_url.replace(/&/, '?'); }
window.location.href = base_url;
return false;
});
$('#sort_rating').change( function() {
var base_url = $(this).data('base-url').replace( /&/g, '&' );
if ( $(this).val() == "lower" ) {
base_url += '&order_by=rating&order=ASC';
} else if ( $(this).val() == "higher" ) {
base_url += '&order_by=rating&order=DESC';
}
if (base_url.indexOf("?") < 0) { base_url = base_url.replace(/&/, '?'); }
window.location.href = base_url;
return false;
});
Theme is the CityTour theme
You can download the older version from links on http://www.themes24x7.com/download-citytours-hotel-tour-booking-wordpress-theme/
Need a solution for Sorting Title Ascending and Descending.