Skip to content

Instantly share code, notes, and snippets.

@propertyhive
propertyhive / gist:fb37720c3b610f63f83faea6fc83ff29
Created September 18, 2024 09:48
Custom Elementor query to get Sold properties
add_action( 'elementor/query/soldpropertyquery', 'sold_only_elementor_query', 99 );
function sold_only_elementor_query( $query )
{
$tax_query = $query->get('tax_query');
$tax_query[] = array(
'taxonomy' => 'availability',
'terms' => array(123), // replace 123 for the 'Sold' ID found under 'Property Hive > Settings > Custom Fields > Availabilities'
'operator' => 'IN',
);
@propertyhive
propertyhive / gist:aa15ae08232f08c0d78aecfda63e2ba8
Last active September 18, 2024 08:45
Import additional statuses from Reapit Foundations format
add_filter( 'propertyhive_reapit_foundations_json_properties_url_parameters', 'set_statuses_in_reapit' );
function set_statuses_in_reapit( $statuses )
{
return array( 'forSale', 'underOffer', 'exchanged' );
}
add_filter( 'propertyhive_reapit_foundations_json_import_lettings_statuses', 'set_lettings_statuses_in_reapit' );
function set_lettings_statuses_in_reapit( $statuses )
{
return array( 'toLet', 'underOffer', 'arrangingTenancy', 'tenancyCurrent' );
@propertyhive
propertyhive / gist:075f10b8b1239c989e4a1130e69a33b0
Last active September 18, 2024 08:45
Filter reapit foundations requests by office
add_filter( 'propertyhive_reapit_foundations_json_properties_url_parameters', 'filter_by_office' );
function filter_by_office( $url_parameters )
{
$url_parameters['officeId'] = array( 'ABC', 'DEF' ); // List of office IDs you DO want to include
return $url_parameters;
}
add_action( "propertyhive_property_imported_agentsinsight_xml", 'set_tenure', 10, 2 );
function set_tenure($post_id, $property)
{
$tenure = '';
if ( isset($property->floor_units) && !empty($property->floor_units) )
{
$floor_units = $property->floor_units->children();
foreach ($floor_units as $floor_unit)
add_filter( 'propertyhive_register_post_type_property', 'change_property_slug' );
function change_property_slug( $args )
{
$args['rewrite'] = array('slug' => 'rent-serviced-offices', 'with_front' => false, 'feeds' => true);
return $args;
}
add_action( "propertyhive_property_imported_jet", "keep_sold_properties_off_market", 10, 2 );
function keep_sold_properties_off_market($post_id, $property)
{
if ( isset($property['selling']['status']) && strtolower($property['selling']['status']) == 'completed' )
{
// Yes this property is completed. Make sure it doesn't go on the market
wp_suspend_cache_invalidation( true );
wp_defer_term_counting( true );
wp_defer_comment_counting( true );
add_filter( 'propertyhive_reapit_foundations_json_import_sales_statuses', 'foundations_selling_statuses' );
function foundations_selling_statuses( $statuses )
{
$statuses[] = 'completed';
return $statuses;
}
add_filter('nav_menu_css_class', 'custom_menu_item_classes', 10, 3);
function custom_menu_item_classes($classes, $item, $args)
{
if ( is_post_type_archive('property') ) {
// Get the current query parameters
if (isset($_GET['department']) && $_GET['department'] == 'residential-lettings') {
// If 'department' is set to 'residential-lettings', highlight the "Property to Rent" menu item.
if ($item->title == 'Property To Rent') {
$classes[] = 'current-menu-item';
add_action( "propertyhive_property_imported_rtdf", 'rtdf_import_stuff', 10, 2 );
function rtdf_import_stuff($post_id, $property)
{
$found_agent = false;
if ( isset($property['assignedAgentName']) && $property['assignedAgentName'] != '' )
{
$args = array(
'post_type' => 'agent',
's' => $property['assignedAgentName'],
'posts_per_page' => 1
add_action( 'propertyhive_property_imported_jupix_xml', 'set_custom_department_on_import', 10, 2);
function set_custom_department_on_import( $post_id, $property )
{
if ( (string)$property->department == 'Agricultural' )
{
update_post_meta( $post_id, '_department', 'rural-agricultural' );
}
if ( (string)$property->developmentOpportunity == '1' )
{