Skip to content

Instantly share code, notes, and snippets.

@JoeHana
Last active June 25, 2019 14:18
Show Gist options
  • Save JoeHana/4b63859ac59bb01907b796fec13c5e1f to your computer and use it in GitHub Desktop.
Save JoeHana/4b63859ac59bb01907b796fec13c5e1f to your computer and use it in GitHub Desktop.
Custom number of baths and beds in Listing Details
<?php
/**
* Custom number of baths and beds in Listing Details
*/
add_filter( 'wpsight_details', 'custom_wpsight_details' );
function custom_wpsight_details( $details ) {
$details['details_1']['data'] = array( '' => __( 'n/d', 'wpcasa' ), '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5' );
$details['details_2']['data'] = array( '' => __( 'n/d', 'wpcasa' ), '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5' );
return $details;
}
@RobertSalguero
Copy link

It works, only change:
return $details;
to
return $data;

Thx

@JoeHana
Copy link
Author

JoeHana commented Jun 25, 2019

True, thanks for the heads up. Snippet has been updated.

@AlviseNicoletti
Copy link

AlviseNicoletti commented Jun 25, 2019

Can you update the code to make it work?

If I apply @RobertSalguero patch it works, but the "bath filter" disappears,
only the "bed filter" works.

Also function custom_wpsight_details( details ) can't be correct,
@JoeHana can you confirm ?

@JoeHana
Copy link
Author

JoeHana commented Jun 25, 2019

@AlviseNicoletti code has been updated, there was still a reference to $data, sorry for that. However, the name of the function itself is up to you actually, it just needs to match the callback for the filter hook. For our example snippets we currently use the original filter hook name together with the prefix "custom". For best practices it would be anyway recommended to apply your own function naming convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment