Skip to content

Instantly share code, notes, and snippets.

@muzahedul03
Created March 1, 2017 07:15
Show Gist options
  • Save muzahedul03/1a642c5976f88ed9b66548ee07cfcb0b to your computer and use it in GitHub Desktop.
Save muzahedul03/1a642c5976f88ed9b66548ee07cfcb0b to your computer and use it in GitHub Desktop.
How Create Dynamic WordPress Menu By php Using Function
<?php
include_once('inc/theme_files.php');
function felxo_theme_menus(){
register_nav_menus(array(
'main_menu' => 'Main menu',
'footer_menu' => 'Footer menu'
));
}
add_action('init', 'felxo_theme_menus');
function felxo_theme_default_menu(){
echo'<ul class="nav navbar-nav">';
if ('page'!=get_option('show_on_front')) {
echo'<li><a href="'.home_url().'/">Home</a></li>';
}
wp_list_pages('title_li=');
echo'</ul>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment