Register Menu in wordpress

PHP Tutorial

Login to admin then go to Pages >> Add New

then create pages you want to show in front end menus. Then

Go to Appearance >> Menus Then create two menu. I create two menu one name as “Main Menu” And “Footer Menu”. Refer image below image

2

After creating menus for pages then we will register the menus. Then copy and paste the below code in function.php file

<?php
add_action( ‘after_setup_theme’, ‘your_theme_setup’ );
function your_theme_setup() {
register_nav_menu( ‘primary’, __( ‘Primary Menu’, ‘your_theme’ ) );
register_nav_menu( ‘footer’, __( ‘Footer Menu’, ‘your_theme’ ) );

}

Where your_theme is name of you theme.

To Display menu in page.php and page-front.php file ,Please copy and paste the below code.
<?php wp_nav_menu( array( ‘theme_location’ => ‘primary’ ) ); ?>

Display menu without ul and li
<?php
$foot_nav = wp_nav_menu( array( ‘container’ => ”, ‘echo’ => ‘0’, ‘theme_location’ => ‘footer’,’link_after’=>’ | ‘ ) );
$foot_nav2 =…

View original post 19 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s