Skip to content

Instantly share code, notes, and snippets.

add_filter( 'propertyhive_electricity_types', 'custom_elec_types' );
function custom_elec_types($types)
{
$types['my_custom_type_1'] = 'My Custom Type 1';
$types['my_custom_type_2'] = 'My Custom Type 2';
return $types;
}
@propertyhive
propertyhive / trigger_portal_update.php
Created November 18, 2024 21:03 — forked from CallumPrimeDev/trigger_portal_update.php
A custom endpoint that updates the price field and opening bid (custom field) for a given property
<?php
add_action('rest_api_init', function () {
register_rest_route('ppa/v1', '/update-property/', array(
'methods' => 'POST',
'callback' => 'update_property',
'permission_callback' => 'basic_auth_permission_check'
));
});
add_filter( 'propertyhive_search_form_fields_after', 'remove_address_three_hidden', 10, 1 );
function remove_address_three_hidden($form_controls)
{
if (isset($form_controls['address_three'])) { unset($form_controls['address_three']); }
return $form_controls;
}
add_filter( "houzez_property_feed_properties_due_import_alto", 'specific_firmid', 10, 2 );
function specific_firmid( $properties, $import_id )
{
$new_properties = array();
foreach ( $properties as $property )
{
$property_attributes = $property->attributes();
if ( (string)$property_attributes['firmid'] == '38942' )
add_filter( 'propertyhive_property_query_meta_query', 'filter_search_by_address_three', 10, 2 );
function filter_search_by_address_three( $meta_query, $query )
{
if ( isset( $_REQUEST['address_three'] ) )
{
$meta_query[] = array(
'key' => '_address_three',
'value' => sanitize_text_field($_REQUEST['address_three']),
);
}
add_filter( 'propertyhive_search_form_fields_after', 'edit_property_search_form_fields' );
function edit_property_search_form_fields($fields)
{
global $wpdb;
$options = array('' => 'No Preference');
// Query to get distinct meta values for the '_building' meta key
$results = $wpdb->get_col(
$wpdb->prepare(
add_action( 'elementor/query/allonmarketpropertyquerynoordering ', 'query_but_random', 99 );
function query_but_random( $query )
{
PH()->query->property_query( $query );
$query->set( 'orderby', 'rand' );
// Set the custom post type
$query->set( 'post_type', [ 'property' ] );
@propertyhive
propertyhive / gist:a4aa8db61322dd8878251179e3fb0c8d
Created October 23, 2024 11:32
Only import properties from Loop with an image present
add_filter( "propertyhive_loop_json_properties_due_import", 'filter_out_properties_with_no_images', 10, 2 );
function filter_out_properties_with_no_images($properties, $import_id)
{
$new_properties = array();
foreach ($properties as $property)
{
if ( isset($property['images']) && is_array($property['images']) && !empty($property['images']) )
{
// only return if images present
add_action('pre_get_posts', 'to_let_only_by_default');
function to_let_only_by_default($q)
{
if (is_admin())
return;
if (!$q->is_main_query())
return;
if (!$q->is_post_type_archive('property') && !$q->is_tax(get_object_taxonomies('property')))
add_filter( 'propertyhive_search_form_fields_after', 'add_form_control_class_to_form_fields', 99 );
function add_form_control_class_to_form_fields($fields)
{
$new_fields = array();
foreach ( $fields as $field )
{
$field['class'] = 'form-control';
$new_fields[] = $field;
}