Adding Navbar to Page.php
-
Hope this is in the right place.
I am trying do this without knowing if it’s possible (as usual haha) but what I have done so far seems to work up to a point.
I’m using the 2012 theme (with child) what I want to do is put the standard navbar menu on the home page template ONLY.
So taking the bull by the horns, I took the navbar code from the header.php file and pasted it into the page-templates/front-page.php and thought that would do the trick (poor fool that I am)
Although it has worked somewhat in that it has put all the navigation links in a vertical list on the front-page.php but…
… unlike me I’m sure you coders will know what the problem is going to be viz…
I have lost the horizontal style from the css somewhere along the way and of course the menu Javascript is not working either.
Yet again I have no idea how to put this right, if some valiant soul can please help me get this working correctly I will be eternally grateful.
Apart from jumping off a bridge, what are my next steps?======================
This is the code snippet from the header.php I pasted in
<nav id="site-navigation" class="main-navigation" role="navigation"> <button class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></button> <a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"><?php _e( 'Skip to content', 'twentytwelve' ); ?></a> <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?> </nav><!-- #site-navigation -->
this is the code that is in the front page.php template to save you lookinh it up.
<?php /** * Template Name: Front Page Template * * Description: A page template that provides a key component of WordPress as a CMS * by meeting the need for a carefully crafted introductory page. The front page template * in Twenty Twelve consists of a page content area for adding text, images, video -- * anything you'd like -- followed by front-page-only widgets in one or two columns. * * @package WordPress * @subpackage Twenty_Twelve * @since Twenty Twelve 1.0 */ get_header(); ?> <div id="primary" class="site-content"> <div id="content" role="main"> <?php while ( have_posts() ) : the_post(); ?> <?php if ( has_post_thumbnail() ) : ?> <div class="entry-page-image"> <?php the_post_thumbnail(); ?> </div><!-- .entry-page-image --> <?php endif; ?> <?php get_template_part( 'content', 'page' ); ?> <?php endwhile; // end of the loop. ?> </div><!-- #content --> </div><!-- #primary --> <?php get_sidebar( 'front' ); ?> <?php get_footer(); ?>
and this is where I have pasted the header code into front page.php
get_header(); ?> <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script> <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?> <nav id="site-navigation" class="main-navigation" role="navigation"> <button class="menu-toggle"><?php _e( 'Menu', 'twentytwelve' ); ?></button> <a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?>"></nav><!-- #site-navigation --> <?php _e( 'Skip to content', 'twentytwelve' ); ?></a> </nav><!-- #site-navigation --> <div id="primary" class="site-content"> <div id="content" role="main"> <?php while ( have_posts() ) : the_post(); ?> <?php if ( has_post_thumbnail() ) : ?> <div class="entry-page-image"> <?php the_post_thumbnail(); ?> </div><!-- .entry-page-image --> <?php endif; ?> <?php get_template_part( 'content', 'page' ); ?> <?php endwhile; // end of the loop. ?> </div><!-- #content --> </div><!-- #primary -->
Standing by, but not holding my breath in case I have posted in the wrong place ??
- The topic ‘Adding Navbar to Page.php’ is closed to new replies.