Skip to content

Instantly share code, notes, and snippets.

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')) {
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;
}
@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
}
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 !== '' ) {
add_shortcode( 'propertyhive_map_search_custom', 'propertyhive_map_search_custom_shortcode' );
function propertyhive_map_search_custom_shortcode( $atts )
{
global $wp_query, $post, $wpdb;
$query = $wp_query->request;
$current_settings = get_option( 'propertyhive_map_search', array() );
$additional_attributes = '';
add_filter( 'propertyhive_shortcode_properties_query', 'filter_shortcode_by_language', 10, 2 );
add_filter( 'propertyhive_shortcode_recent_properties_query', 'filter_shortcode_by_language', 10, 2 );
add_filter( 'propertyhive_shortcode_featured_properties_query', 'filter_shortcode_by_language', 10, 2 );
add_filter( 'propertyhive_shortcode_similar_properties_query', 'filter_shortcode_by_language', 10, 2 );
function filter_shortcode_by_language($args, $atts)
{
// Get the current language
$current_language = apply_filters( 'wpml_current_language', NULL );
$tax_query = ( ( isset($args['tax_query']) && is_array($args['tax_query']) ) ? $args['tax_query'] : array() );
add_filter( 'propertyhive_get_search_results_ordering_args', 'order_by_date_old' );
function order_by_date_old($args)
{
if ( isset( $_GET['orderby'] ) && $_GET['orderby'] != '' )
{
$orderby_value = explode( '-', $_GET['orderby'] );
$orderby = esc_attr( $orderby_value[0] );
$order = ! empty( $orderby_value[1] ) ? $orderby_value[1] : 'DESC';
switch ( $orderby )
@propertyhive
propertyhive / gist:de019c8fe793f790908a476506745b8d
Created April 25, 2024 18:01
Run media queue before the property imports run
add_action( 'propertyhive_before_property_import_cron', 'run_media_queue', 1 );
function run_media_queue()
{
do_action('phpropertydownloadimportmediacronhook');
}