Last active
December 11, 2015 01:58
-
-
Save mgerring/4526789 to your computer and use it in GitHub Desktop.
Automatically look for different templates depending on what page template you're using
This file contains hidden or 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
<?php | |
function get_page_template_name() { | |
global $wp_query; | |
$template_name = get_post_meta( $wp_query->post->ID, '_wp_page_template', true ); | |
return str_replace('.php','',$template_name); | |
} |
This file contains hidden or 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
<?php get_template_part( 'nav', get_page_template_name() ); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment