Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save propertyhive/e1dcc63416bdb94de6cfa87664a5023b to your computer and use it in GitHub Desktop.
Save propertyhive/e1dcc63416bdb94de6cfa87664a5023b to your computer and use it in GitHub Desktop.
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