Created
May 7, 2024 09:31
-
-
Save propertyhive/7ea3588ecc5921719cb71d4c916073f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) { | |
$property = new PH_Property(get_the_ID()); | |
$property_type = $property->property_type; | |
if ('Serviced Apartments' === $department) { | |
$template_id = 281540; // ID of your Elementor template for 'investment' | |
} else { | |
$template_id = 281535; // ID of your Elementor template for others | |
} | |
$wanted_template = $theme_builder->get_document($template_id); // Replace 281540 with the ID of the template you want to display. | |
$wanted_template->print_content(); // Display wanted template. | |
$manager->set_is_printed('single', key($current_template)); // Notify Manager that the single location was rendered. | |
} | |
} | |
add_action('elementor/theme/before_do_single', 'screddit_filter_single_elementor_template', 11); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment