Skip to content

Instantly share code, notes, and snippets.

@MjHead
Created June 2, 2023 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MjHead/e27b0938742d2a700335451539901d88 to your computer and use it in GitHub Desktop.
Save MjHead/e27b0938742d2a700335451539901d88 to your computer and use it in GitHub Desktop.
Change template for JetThemeCore plugin based on the option value.
<?php
add_filter( 'jet-theme-core/location/render/template-id', function( $template_id ) {
/**
* 123 - is ID of initial template you set in ThemeCore (could be found in adress bar)
* 'alternate-value' - is value of option which enables alternative layout for this page
* page-slug and option-name - there are option page slug and option name itself which are responsible for layout
*/
if ( 123 === $template_id && 'alternate-value' === jet_engine()->listings->data->get_option( 'page-slug::option-name' ) ) {
// 321 - is alternative template, coud be anything - elementor templte, themecore template, listing template etc.
$template_id = 321;
}
return $template_id;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment