WordPress #4: Create a constant footer on every page

On WordPress

Appearance > Menus > create a new menu > Name the menu ‘Footer’.

Select a menu to edit: Footer > Tick the pages boxes to be included in the menu > Add to Menu.

Code

On functions.php add,

function mytheme_register_nav_menus() {
	register_nav_menus( array(
	        'primary' => __( 'Primary Menu', 'Custom Menu' ),
	        'footer' => __( 'Footer', 'Custom Menu' )
	)); 
}
add_action( 'after_setup_theme', 'mytheme_register_nav_menus' );

On footer.php add,

<html>
	<head>
	        <!-- Bootstrap -->
    	        <link rel="stylesheet" href="css/bootstrap.css">
		<style>
			footer{
				background-color: #fff;
			}

			ul#menu-footer{
			   list-style: none;
			   text-align: left;
			}

			ul#menu-footer li{
				list-style: none;
    			padding: 10px;
			}
		</style>
	</head>
	<footer>
		<a class="navbar-brand mb-0 pl-5 h1" href="/">am</a>
		<?php wp_nav_menu( array( 
			'container_class' => 'footer-nav', 
			'theme_location' => 'footer' ) );  
		?>

	</footer>
</html>

On blog.php or other pages add,

<?php get_footer();?>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *