Skip to content

Instantly share code, notes, and snippets.

@g-maclean
g-maclean / snippet.php
Created January 7, 2026 22:09
Property Hive - redirect off market property URLs
add_action( 'template_redirect', 'ph_redirect_off_market_properties' );
function ph_redirect_off_market_properties() {
// Only run on single property posts
if ( ! is_singular( 'property' ) ) {
return;
}
// Allow admins to view off-market properties
if ( current_user_can( 'administrator' ) ) {
@g-maclean
g-maclean / snippet.php
Created December 23, 2025 03:50
Property Hive - Import Retirement property and furnishing
add_action( "propertyhive_property_imported_street_json", 'import_furnished_and_type', 10, 2 );
function import_furnished_and_type( $post_id, $property ) {
//furnished
if ( isset( $property['lettingsListing']['furnished'] ) && !empty( $property['lettingsListing']['furnished'] ) ) {
$furnished = sanitize_text_field( $property['lettingsListing']['furnished'] );
$allowed_values = array( 'Furnished', 'Unfurnished', 'Part Furnished' );
if ( in_array( $furnished, $allowed_values ) ) {
wp_set_object_terms( $post_id, $furnished, 'furnished' );
@g-maclean
g-maclean / snippet.php
Created December 15, 2025 20:13
Property Hive - Agency Pilot - Import all commercial
add_filter( "propertyhive_agency_pilot_api_request_body", 'include_completed_in_body' );
function include_completed_in_body($body)
{
$body['FilterOptions']['ActiveOnly'] = false;
return $body;
}
add_filter( "propertyhive_agency_pilot_api_properties_due_import", 'filter_completed', 10, 3 );
function filter_completed($properties, $options, $token)
{
@g-maclean
g-maclean / snippet.php
Created December 15, 2025 04:35
Property Hive - woocommerce memberships restriction
<?php
/**
* The Template for displaying a single property.
*
* Override this template by copying it to yourtheme/propertyhive/single-property.php
*
* @author PropertyHive
* @package PropertyHive/Templates
* @version 1.0.0
*/
@g-maclean
g-maclean / snippet.php
Last active December 1, 2025 00:14
Property Hive - add a bulk option for removing property media
//adds a new option to the wp bulk options dropdown
// Add a custom bulk action to the dropdown
function add_bulk_delete_media_action($bulk_actions) {
$bulk_actions['delete_attached_media'] = __('Delete Attached Media', 'text-domain');
return $bulk_actions;
}
add_filter('bulk_actions-edit-property', 'add_bulk_delete_media_action');
// Handle the custom bulk action
@g-maclean
g-maclean / snippet.php
Created November 25, 2025 16:48
Property Hive - Sort by Title
// Change default order (optional)
add_filter('propertyhive_default_search_results_orderby', 'change_default_order');
function change_default_order( $orderby )
{
return 'title_asc'; // or return ''; if you want PropertyHive's default
}
// Add new sort options to dropdown
add_filter( 'propertyhive_results_orderby', 'ph_add_custom_title_sorting' );
function ph_add_custom_title_sorting($options)
@g-maclean
g-maclean / snippet.php
Created November 20, 2025 13:34
Property Hive - Reapit - use extra address field for location
add_action( "propertyhive_property_imported_reapit_json", 'assign_location_from_extra_field', 10, 2 );
function assign_location_from_extra_field( $post_id, $property ) {
$location_set = false;
if ( isset( $property['address']['line3'] ) && trim( $property['address']['line3'] ) != '' ) {
$reapit_location = trim( $property['address']['line3'] );
$term = term_exists( $reapit_location, 'location' );
if ( $term !== 0 && $term !== null && isset( $term['term_id'] ) ) {
$location_set = true;
wp_set_object_terms( $post_id, array( (int)$term['term_id'] ), 'location' );
}
@g-maclean
g-maclean / snippet.php
Last active November 18, 2025 05:53
Property Hive - Elementor - Similar Properties Query ID
add_action( 'elementor/query/similar_properties_query', function( $query ) {
global $property;
//
// STATIC DEFAULTS (taken from the shortcode)
// https://docs.wp-property-hive.com/article/312-shortcodes-similarproperties
//
$atts = array(
//'per_page' => 2, //unused
@g-maclean
g-maclean / snippet.php
Last active November 4, 2025 13:51
Property Hive - shortcode to output address without number
function ph_address_no_number_shortcode( $atts ) {
global $property;
// Do nothing if $property object isn't available
if ( ! isset( $property ) || ! is_object( $property ) ) {
return '';
}
// Shortcode attributes: separator, optional HTML tag, optional class
$atts = shortcode_atts( array(
@g-maclean
g-maclean / snippet.php
Created October 1, 2025 06:07
PropertyHive - Agent Insight - abbreviated floors / floorunit
add_filter( 'propertyhive_import_agentsinsight_units_description_table_data_columns', 'custom_data_columns' );
function custom_data_columns( $columns )
{
if ( isset($columns['name']) )
{
// Map of codes to labels
$floor_map = array(
'lg' => 'Lower Ground',
'g' => 'Ground',
'm' => 'Mezzanine',