Skip to content

Instantly share code, notes, and snippets.

@mgerring
Last active December 11, 2015 01:58
Show Gist options
  • Save mgerring/4526789 to your computer and use it in GitHub Desktop.
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
<?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);
}
<?php get_template_part( 'nav', get_page_template_name() ); ?>
<header>
<h1 id="logo"><a href="<?php bloginfo('url'); ?>"><?php sc_print_logo(); ?></a></h1>
</header>
<header>
<h1 id="logo"><a href="<?php bloginfo('url'); ?>"><?php sc_print_logo(); ?></a></h1>
<?php wp_nav_menu(array('theme_location'=>'header','container'=>'nav', 'menu_class' => 'menu-container', 'menu_id' => 'nav-top', 'fallback_cb'=>false)); ?>
</header>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment