Skip to content

Instantly share code, notes, and snippets.

add_filter( 'propertyhive_properties_query', 'include_off_market_sold_properties', 10, 2 );
function include_off_market_sold_properties( $args, $atts )
{
if ( isset($atts['availability_id']) && $atts['availability_id'] == 123 )
{
$meta_query = $args['meta_query'];
$new_meta_query = array();
foreach ( $meta_query as $meta_query_el )
{
add_action( "propertyhive_property_imported_kyero_xml", 'kyero_property_imported', 10, 2 );
function kyero_property_imported($post_id, $property)
{
$display_address = (string)$property->location_detail;
if ( $display_address == '' )
{
$display_address = (string)$property->town;
}
if ( $display_address == '' )
{
// Set flags in Property Hive based off attributes in Loop
add_action("propertyhive_property_imported_loop_json", 'import_flags', 10, 2);
function import_flags($post_id, $property)
{
// Temporarily disable some WordPress actions for performance
wp_suspend_cache_invalidation(true);
wp_defer_term_counting(true);
wp_defer_comment_counting(true);
@propertyhive
propertyhive / gist:b8f26263646d2fbfd8718e9a5b1057c8
Last active May 1, 2024 12:53
Auto create locations from loop import
add_action( "propertyhive_property_imported_loop_json", 'insert_non_existant_locations', 10, 2 );
function insert_non_existant_locations($post_id, $property)
{
if ( isset($property['address_Locality']) && $property['address_Locality'] != '' )
{
$term = get_term_by( 'name', $property['address_Locality'], 'location' );
if ( $term === FALSE )
{
$args = array();
wp_insert_term( $property['address_Locality'], 'location', $args );
add_action( "propertyhive_property_imported_vebra_api_xml", "correct_property_auction_department", 10, 2 );
function correct_property_auction_department($post_id, $property)
{
$price_attributes = $property->price->attributes();
if ( isset($price_attributes['qualifier']) && strpos(strtolower($price_attributes['qualifier']), 'auction') !== false )
{
update_post_meta( $post_id, '_department', 'auction' );
}
}
function screddit_filter_single_elementor_template($manager)
{
if (ElementorPro\Modules\ThemeBuilder\Module::is_preview()) // Do not change content when editing.
return;
$theme_builder = ElementorPro\Modules\ThemeBuilder\Module::instance();
$current_template = $theme_builder->get_conditions_manager()->get_documents_for_location('single');
if (is_singular('property')) {
@propertyhive
propertyhive / gist:0f4051f4c9698d610eab6e46ac6124ba
Last active April 30, 2024 11:57
Different single post elementor template based on meta
add_filter('template_include', 'custom_property_template_redirect', 99);
function custom_property_template_redirect($template) {
if (is_singular('property')) {
$department = get_post_meta(get_the_ID(), '_department', true);
if ('auction' === $department) {
$template_id = 123; // ID of your Elementor template for 'auction'
} else {
$template_id = 456; // ID of your Elementor template for others
}
function custom_rewrite_basic() {
// The following rule maps /locations/east/ to the search results page with a specific location ID
add_rewrite_rule('^locations/east/?$', 'index.php?pagename=search_results&location=241', 'top');
}
add_action('init', 'custom_rewrite_basic');
function register_query_vars( $vars ) {
$vars[] = 'location'; // Add 'location' to the recognized query vars
return $vars;
}
add_filter( 'propertyhive_property_import_rtdf_mandatory_fields_send', 'custom_mandatory_rtdf_fields' );
function custom_mandatory_rtdf_fields($mandatory_fields)
{
unset($mandatory_fields['property']['address']['house_name_number']);
return $mandatory_fields;
}
add_action( "propertyhive_property_imported_caldes_xml", 'append_brochure_17_to_description', 10, 2 );
function append_brochure_17_to_description($post_id, $property)
{
$descriptions = 0;
if ( (string)$property->brochure_text !== '' ) {
update_post_meta( $post_id, '_description_name_' . $descriptions, '' );
update_post_meta( $post_id, '_description_' . $descriptions, (string)$property->brochure_text );
++$descriptions;
}
if ( (string)$property->brochure_17 !== '' ) {