Skip to content

Instantly share code, notes, and snippets.

@generatepress
Created October 14, 2015 05:09
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 generatepress/84bae0e5ac0d94ce46f7 to your computer and use it in GitHub Desktop.
Save generatepress/84bae0e5ac0d94ce46f7 to your computer and use it in GitHub Desktop.
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