Pagination working in the search

This commit is contained in:
Will Bradley 2014-02-26 13:06:17 -07:00
parent f81ebc88a1
commit 6a8af48e0a

8
classes/xml-search.php Normal file → Executable file
View File

@ -51,10 +51,12 @@ if ( !class_exists( 'SM_XML_Search' ) ){
$limit = apply_filters( 'sm-xml-search-limit', $limit ); $limit = apply_filters( 'sm-xml-search-limit', $limit );
if ( $input['page'] && $input['page'] < 250 ) if ( $input['page'] && $input['page'] < 250 ) {
$offset = 'OFFSET ' . ( absint($input['page']) - 1) * $limit; $offset = 'OFFSET ' . ( absint($input['page']) - 1) * absint( $input['limit'] );
else }
else {
$offset = ''; $offset = '';
}
// Locations within specific distance or just get them all? // Locations within specific distance or just get them all?
$distance_select = $wpdb->prepare( "( 3959 * ACOS( COS( RADIANS(%s) ) * COS( RADIANS( lat_tbl.meta_value ) ) * COS( RADIANS( lng_tbl.meta_value ) - RADIANS(%s) ) + SIN( RADIANS(%s) ) * SIN( RADIANS( lat_tbl.meta_value ) ) ) ) AS distance", $input['lat'], $input['lng'], $input['lat'] ) . ', '; $distance_select = $wpdb->prepare( "( 3959 * ACOS( COS( RADIANS(%s) ) * COS( RADIANS( lat_tbl.meta_value ) ) * COS( RADIANS( lng_tbl.meta_value ) - RADIANS(%s) ) + SIN( RADIANS(%s) ) * SIN( RADIANS( lat_tbl.meta_value ) ) ) ) AS distance", $input['lat'], $input['lng'], $input['lat'] ) . ', ';