Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Override Generate Sections Custom Page Template
add_action( 'wp','generate_override_sections_template' );
function generate_override_sections_template()
{
remove_filter( 'template_include', 'generate_sections_page_template' );
}
add_filter( 'template_include', 'generate_sections_custom_page_template' );
function generate_sections_custom_page_template( $template ) {
global $post;
$use_sections = ( isset( $post ) ) ? get_post_meta( $post->ID, '_generate_use_sections', TRUE) : '';
if ( isset( $use_sections['use_sections'] ) && 'true' == $use_sections['use_sections'] ) {
$new_template = get_stylesheet_directory() . '/generate-sections-page-template.php';
if ( '' != $new_template ) {
return $new_template;
}
}
return $template;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment