Skip to content

Instantly share code, notes, and snippets.

@g-maclean
g-maclean / gist:4c61cf4950f33a36d4f229515a2be4b2
Last active October 24, 2024 10:36
Use unit ref as title for unit imported from Arthur
add_action( "propertyhive_property_unit_imported_arthur_json", 'use_unit_ref_as_post_title', 10, 2 );
function use_unit_ref_as_post_title($post_id, $unit)
{
$new_title = '';
if ( isset($unit['unit_ref']) && $unit['unit_ref'] != '' )
{
$new_title = $unit['unit_ref'];
}
else{
return;
@g-maclean
g-maclean / gist.php
Created October 24, 2024 15:58
PropertyHive elementor query with on-the-maket check but no ordering enforced
add_action( 'elementor/query/allonmarketpropertyquerynoordering ', 'query_but_no_ordering', 99 );
function query_but_no_ordering( $query )
{
PH()->query->property_query( $query );
// Set the custom post type
$query->set( 'post_type', [ 'property' ] );
// ensure a department is set as not set by default from property_query
$meta_query = $query->get('meta_query');
@g-maclean
g-maclean / snippet.php
Created November 4, 2024 11:59
Property Hive available-from custom field added as new dropdown in search
add_filter('propertyhive_search_form_fields_default', 'edit_default_property_search_form_fields', 99);
function edit_default_property_search_form_fields($fields)
{
$fields['available_from'] = array(
'type' => 'select',
'label' => __('Available From', 'propertyhive'),
'show_label' => true,
'before' => '<div class="control control-available_from">',
'options' => array(
'' => 'No Preference',
@g-maclean
g-maclean / snippet.php
Created November 11, 2024 16:39
PropertyHive - Change department label on search form
add_action('propertyhive_search_form_fields', 'change_search_form_labels', 1, 99);
function change_search_form_labels($form_controls){
if(isset($form_controls['department']['options']['rooms'])){
$form_controls['department']['options']['rooms'] = "Rooms To Let";
}
return $form_controls;
}
add_filter( 'propertyhive_reapit_foundations_json_import_lettings_statuses', 'include_new_lettings_status_reapit' )
function include_new_lettings_status_reapit($statuses)
{
return array( 'toLet', 'underOffer', 'let' );
}
@g-maclean
g-maclean / snippet.php
Created November 14, 2024 23:53
PropertyHive - regal rentals viewing form
function rr_viewing_shortcode() {
global $property;
$ref = $property->reference_number;
$address = $property->address_name_number;
ob_start();
?>
<div data-paperform-id="regal-rentals-viewing-request-form" data-prefill="Ref=<?php echo $ref;?>&Address=<?php echo $address;?>"></div>
@g-maclean
g-maclean / snippet.php
Created November 15, 2024 11:30
PropertyHive - match address 2 & 3 in similar properties shortcode
add_filter('propertyhive_shortcode_similar_properties_query','match_addresses_2_and_3', 2, 10);
function match_addresses_2_and_3($args, $atts){
$original_match_query = $args['meta_query'][3];
if($original_match_query['key']!='_address_three'){return $args;}
$new_match_query[] = $original_match_query;
$new_match_query[] = array("key" => "_address_two", "value" => $original_match_query["value"]);
$args['meta_query'][3] = array('relation' => 'OR', $new_match_query);
@g-maclean
g-maclean / snippet.php
Created November 19, 2024 16:12
PropertyHive - shortcode for displaying room counts
add_shortcode("room_counts", "output_room_counts");
function output_room_counts(){
global $property;
$bedrooms = $property->bedrooms;
$bathrooms = $property->bathrooms;
$reception_rooms = $property->reception_rooms;
$rooms= [];
if ( !empty($bedrooms) ) {
@g-maclean
g-maclean / snippet.php
Last active April 4, 2025 10:12
PropertyHive - remove enquiry button from sold properties
add_action("propertyhive_property_actions_start", "remove_enquiry_button_for_sold");
function remove_enquiry_button_for_sold(){
global $property;
if( in_array($property->availability, ['Sold STC']) ){
remove_action( 'propertyhive_property_actions_list_start', 'propertyhive_make_enquiry_button', 10 );
}
}
@g-maclean
g-maclean / snippet.php
Last active March 26, 2025 16:47
PropertyHive - Use different description language
add_action( 'propertyhive_property_imported_kyero_xml', 'use_nl_description', 10, 2 );
function use_nl_description( $post_id, $property ) {
$desc = (string)$property->desc->nl;
$post = array(
'ID' => $post_id,
'post_excerpt' => $desc,
);