banner-image

Display menu using WP Query on custom php template

If you need to display the WordPress menu on a custom header.php file or on any page/post templates, you need to use the below code directly on that template file. This will call the total menu with all the classes and styles automatically from the WordPress menu system.

wp_nav_menu( array('theme_location' => 'primary', 'container_class'=> 'nav', 'menu_class'=>'', 'menu_id'=>'m'));

Also, if you need to call the only menu name and menu links separately, then you have to use the below method on your PHP template files directly.

<?php 
$items = wp_get_nav_menu_items('Footer menu');
if($items){
  foreach($items as $item){ ?>
      <a href="<?php echo $item->url; ?>"><?php echo $item->title; ?></a>
<?php }} ?>

 

For more details visit here.

Do You Want To Boost Your Business?

drop us a line and keep in touch