Custom number of beds and baths (modified code for use with .25, .5 and .75 values.)
<?php
/**
* Custom number of beds and baths
*/
add_filter( 'wpsight_standard_details', 'custom_standard_details', 100 );
function custom_standard_details( $details ) {
// Beds
$details['details_1']['data'] = array(
'' => __( 'n/d', 'wpsight' ),
'1000' => '1',
'2000' => '2',
'3000' => '3',
'5000' => '5',
'6000' => '6',
'7000' => '7',
'8000' => '8',
'9000' => '9',
'10000' => '10'
);
// Baths
$details['details_2']['data'] = array(
'' => __( 'n/d', 'wpsight' ),
'1000' => '1',
'1250' => '1.25',
'1500' => '1.5',
'1750' => '1.75',
'2000' => '2',
'2250' => '2.25',
'2500' => '2.5',
'2750' => '2.75',
'3000' => '3',
'3250' => '3.25',
'3500' => '3.5',
'3750' => '3.75',
'4000' => '4',
'4250' => '4.25',
'4500' => '4.5',
'4750' => '4.75',
'5000' => '5',
'5250' => '5.25',
'5500' => '5.5',
'5750' => '5.75'
);
return $details;
}
/**
* Remove zeros from listing details
*/
add_filter( 'wpsight_listing_details', 'custom_listing_details', 100 );
function custom_listing_details( $details ) {
// Get post ID from $post
if( empty( $post_id ) )
$post_id = get_the_ID();
// If still empty, return false
if( empty( $post_id ) )
return false;
// Get post custom data
$post_custom = get_post_custom( $post_id );
// Get standard details
$standard_details = wpsight_standard_details();
// Create markup
$details = '<div class="listing-details-overview clearfix">';
// Loop through required details
if( empty( $details_nr ) )
$details_nr = 3;
for( $i = 1; $i <= $details_nr; $i++ ) {
if( ! empty( $post_custom['_details_' . $i][0] ) ) {
$details .= '<span class="listing-details-' . $i . '">';
$details .= str_replace( '000', '', str_replace( '250', '.25', str_replace( '500', '.5', str_replace( '750', '.75', str_replace( '5000', '5', $post_custom['_details_' . $i][0] ) ) ) ) ). ' ';
$details .= wpsight_get_measurement_units ( $standard_details['details_' . $i]['unit'] );
$details .= '</span>' . "\n";
}
}
// Display formatted listing price
$details .= '<span class="listing-price">' . wpsight_get_price( $post_id ) . '</span>' . "\n";
// Close markup
$details .= '</div><!-- .listing-details -->';
return $details;
}
/**
* Search for exact bedrooms/bathrooms
*/
add_filter( 'wpsight_search_form_details', 'custom_search_form_details_exact', 100 );
function custom_search_form_details_exact( $details ) {
$details['details_1']['data_compare'] = '=';
$details['details_2']['data_compare'] = '=';
return $details;
}
/**
* Remove zeros from single listing details
*/
add_filter( 'wpsight_widget_listing_details', 'custom_widget_listing_details', 100 );
add_filter( 'wpsight_listing_details_shortcode', 'custom_widget_listing_details', 100 );
function custom_widget_listing_details( $details ) {
return str_replace( '000', '', str_replace( '250', '.25', str_replace( '500', '.5', str_replace( '750', '.75', str_replace( '5000', '5', $details ) ) ) ) );
}