Skip to content

Instantly share code, notes, and snippets.

@g-maclean
g-maclean / snippet.php
Created July 14, 2026 16:32
Property Hive - Kato - Import Dates and use one for date sorting
add_action( 'propertyhive_property_imported_agentsinsight_xml', 'import_kato_dates', 10, 2 );
function import_kato_dates( $post_id, $property )
{
// Created At
if ( isset( $property->created_at ) && (string) $property->created_at != '' ) {
update_post_meta( $post_id, '_kato_created_at', (string) $property->created_at );
}
// Last Updated
@g-maclean
g-maclean / snippet.php
Created July 2, 2026 12:58
Property Hive - Custom property details shortcode
/**
* Custom Property details shortcode
* Usage: [property_details]
*/
function my_property_details_shortcode() {
// Make sure Property Hive is active.
if ( ! class_exists( 'PH_Property' ) ) {
return '';
}
@g-maclean
g-maclean / snippet.php
Last active June 11, 2026 02:36
Property Hive - Reapit - Alternate URL with ref
add_action( 'propertyhive_property_imported_reapit_foundations_json', 'reapit_alt_url', 10, 2 );
function reapit_alt_url( $post_id, $property ) {
// Used for the post title
$full_address_parts = array_filter( array(
$property['address']['line1'] ?? '',
$property['address']['line2'] ?? '',
$property['address']['line3'] ?? '',
$property['address']['line4'] ?? '',
@g-maclean
g-maclean / snippet.php
Created May 27, 2026 06:29
Property Hive - Order offices in search dropdown
add_action( 'pre_get_posts', function( $query ) {
if ( is_admin() ) {
return;
}
// Adjust this condition if the plugin uses a shortcode/custom query.
if ( $query->get( 'post_type' ) !== 'office') {
return;
}
@g-maclean
g-maclean / snippet.php
Last active May 19, 2026 01:53
Property Hive - ValPal - Change notification address based on postcode & department
add_filter('propertyhive_valpal_email_to', 'my_valpal_email_recipient', 10, 4);
function my_valpal_email_recipient($to, $post_data, $result, $return) {
// Make sure required values exist
if (empty($return['postcode']) || empty($post_data['valuation_type'])) {
return $to;
}
$postcode = strtoupper(trim($return['postcode']));
@g-maclean
g-maclean / snippet.php
Created May 14, 2026 18:01
Property Hive - Reapit - Only import the first part of postcodes
add_filter( "propertyhive_reapit_foundations_json_properties_due_import", 'strip_second_part_of_postcode' );
function strip_second_part_of_postcode( $properties )
{
foreach ( $properties as &$property )
{
if ( !empty($property['address']['postcode']) )
{
// Trim whitespace first
$postcode = trim($property['address']['postcode']);
@g-maclean
g-maclean / snippet.php
Last active May 13, 2026 22:54
Property Hive - Sort shortcode results by meta field
function order_shortcode_by_available_change_date( $args, $atts )
{
global $post;
if ( $post->ID == 11500 ) // track record page only
{
// Only include properties where _site_area_to > 100000
$args['meta_query'] = array(
array(
'key' => '_site_area_to',
@g-maclean
g-maclean / snippet.php
Created April 29, 2026 17:03
Property Hive - Street - Use public address as title and URL
add_action('propertyhive_property_imported_street_json', 'use_public_address_as_title', 10, 2);
function use_public_address_as_title($post_id, $property)
{
if (isset($property['public_address']) && $property['public_address'] != '')
{
$new_title = wp_strip_all_tags($property['public_address']);
$new_slug = sanitize_title($new_title);
// Default excerpt
@g-maclean
g-maclean / snippet.php
Last active May 5, 2026 07:34
Property Hive - Real time feed - override To Rent price qualifier
add_filter( 'ph_rtdf_send_request_data', 'set_price_qualifier_for_commercial_rent', 10, 2 );
function set_price_qualifier_for_commercial_rent( $request_data, $post_id ) {
$property = new PH_Property( $post_id );
if ( ! $property ) {
return $request_data;
}
@g-maclean
g-maclean / snippet.php
Last active April 20, 2026 19:01
Property Hive - rightmove - add floor area (for residential)
add_filter( 'ph_rtdf_send_request_data', 'amend_property_request_data', 10, 2 );
function amend_property_request_data( $request_data, $post_id )
{
$floor_area_raw = get_post_meta($post_id, '_floor_area', true);
if ( !empty($floor_area_raw) )
{
// Remove anything that isn't a number or decimal point
$floor_area = preg_replace('/[^0-9.]/', '', $floor_area_raw);