Reply To: How to get the menu to show on Blank page template

#3745
Ron
Keymaster

Before anything else, the next update of the theme has some changes particularly on the menu. You might want to get the latest version now before it goes live on wordpress.org. You can get it here https://ronangelo.com/frontier/

There are 2 ways to add your menu on the Blank Page.

Option 1 Just copy the html structure of the menu then paste it on the editor. This means you would have to update the page separately if you update the menu.

– Go to any page with the menu. Right-click then select “View Page Source”
– Copy from <nav id=”nav-main”> up to </nav>
– Then paste that on top of your page’s content on the editor.

Option 2 Add a piece of code on the functions.php. You must be using a child-theme. With this, you won’t have to update the page separately if you update the menu. On your child theme add this code. Replace ‘2’ on ‘is_page(2)’ with your specific page’s ID.

function blank_page_add_menu( $content ) {
	if ( is_page(2) ) {
		$my_menu = '<nav id="nav-main">';
		$my_menu .= wp_nav_menu( array(
			'echo' => '0',
			'theme_location' => 'frontier-menu-primary',
			'container' => false,
			'menu_class' => 'nav-main',
			'fallback_cb' => 'wp_page_menu')
			);
		$my_menu .= '</nav>';
		$content = $my_menu . $content;
	}
	return $content;
}
add_filter( 'the_content', 'blank_page_add_menu' );