最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - How can I show a custom WordPress menu anywhere I want on my website?

programmeradmin0浏览0评论

I went into Appearances > Menus and created my own menu called "default menu." Then I tried to include it in my WordPress theme, but was unsuccessful. I am trying to include it just before the footer.

When I tried with this code:

<?php wp_nav_menu('theme_location=header-menu&container=false&menu_id='); ?>

it just gave me a list of all the pages I've created.

So then I tried with:

<?php echo do_shortcode('[listmenu menu="default menu"]'); ?>

and then it just echoed what was in the PHP tag.

Please tell me what I should be doing differently. Thank you.

I went into Appearances > Menus and created my own menu called "default menu." Then I tried to include it in my WordPress theme, but was unsuccessful. I am trying to include it just before the footer.

When I tried with this code:

<?php wp_nav_menu('theme_location=header-menu&container=false&menu_id='); ?>

it just gave me a list of all the pages I've created.

So then I tried with:

<?php echo do_shortcode('[listmenu menu="default menu"]'); ?>

and then it just echoed what was in the PHP tag.

Please tell me what I should be doing differently. Thank you.

Share Improve this question asked Apr 29, 2019 at 15:30 argoncobaltargoncobalt 31 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

wp_nav_menu() is the correct function to display a menu.

Is the default menu assigned to the location you've specified and if so, are there any items assigned to that menu?

Menus without any items assign will display pages by default. You could try adding the menu param with a value of the name of your default menu.

发布评论

评论列表(0)

  1. 暂无评论