Created
April 30, 2024 12:17
-
-
Save propertyhive/e1dcc63416bdb94de6cfa87664a5023b 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')) { | |
$department = get_post_meta(get_the_ID(), '_department', true); | |
if ('auction' === $department) { | |
$template_id = 281540; // ID of your Elementor template for 'auction' | |
} 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