Last active
April 30, 2024 11:57
-
-
Save propertyhive/0f4051f4c9698d610eab6e46ac6124ba to your computer and use it in GitHub Desktop.
Different single post elementor template based on meta
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
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 | |
} | |
$elementor_instance = \Elementor\Plugin::instance(); | |
return $elementor_instance->frontend->get_builder_content_for_display($template_id); | |
} | |
return $template; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment