How to Add WordPress Menu Location [Tutorial]

This guidance will explain you how to add WordPress menu location to your theme. 有时你可能需要添加一个额外的导航菜单,其中包含重要的或经常使用的链接,以增加WordPress站点的可用性.

To create a new menu you need to edit your theme files. Before making changes to any of your core files, it's best to backup your entire site in case something goes wrong along the way.

在管理仪表板下添加一个新的菜单位置选项 Appearance > Menus you need to 'register a menu'. All it takes is adding a snippet of code to your 'functions.php' file located under /wp-content/themes/your_theme/ directory on the server.


Hey, you! Have you heard about our new subscription service ONE? If no, just keep reading what I’m telling you about! 我们的新订阅服务ONE可以给你一个极好的机会来节省你的钱,并得到更多的项目. 订阅费用仅为每月19美元,您可以从一个包中下载任何材料. 只要订阅一个,就可以获得无限数量的酷元素! Check out what WordPress 我们现在为您在订阅中选择最合适的主题. Moreover, if you are a blog reader, 使用简单的促销码,您可以获得5%的折扣 BecomeThe1.


Registering New WordPress Add Menu Location

Access your server using ftp client or FileManager provided by your host. Navigate to /wp-content/themes/your_theme/ directory on your server. Open the 'functions.php' file for editing.

how to add menu wordpress

Scroll to the bottom of the file. 如果您只想添加一个菜单,请在新行添加以下代码:

function register_my_menu() {
register_nav_menu('additional-menu',__( 'Additional Menu' ));
}
add_action( 'init', 'register_my_menu' );

In this example, 'Additional Menu' 该名称是否会出现在管理仪表板的菜单页面中. The 'additional-menu' name is what WordPress will understand to execute your code properly.

如果您想在站点中添加多个菜单,请在新行中添加以下代码:

function register_my_menus() {
register_nav_menus(
array(
 'additional-menu' => __( 'Additional Menu' ),
 'another-menu' => __( 'Another Menu' ),
 'extra-menu' => __( 'Extra Menu' )
 )
 );
}
add_action( 'init', 'register_my_menus' );

You can add as many new menus as you'd like with this method. The same rules will apply when naming them. Save the changes you made to the file.


Creating New WordPress Add Menu Location via Dashboard

Head over to Appearance > Menus in your dashboard. 您会注意到您的新菜单将被列在主题位置 Manage Location section.

add navigation menu wordpress

Feel free to create a new menu or use an existing one. Once you have created a new menu, 您还可以在“管理位置”选项卡下管理显示的位置.

add navigation menu wordpress

WordPress Add Menu Location to Your Theme

这是你需要决定把菜单放在哪里的地方. 如果您希望菜单显示在页面顶部,则需要编辑 'header.php' file. 你也可以把它放在页脚这意味着你可以编辑 'footer.php' file. 您甚至可以通过编辑其模板文件在页面上显示菜单,或者在侧边栏上编辑其 'sidebar.php' file.

You can place your new menu where ever you'd like. 以下是你需要添加到这些位置的最少代码量:

 'additional-menu' ) ); ?>

Where additional-menu is your new menu.

你可能想用CSS来设计你的菜单样式,这样它就不仅仅是基本的功能,而且看起来也很棒. 要做到这一点,你需要创建一个类,并用下面的代码将它添加到你的主题中:

 'additional-menu', 'container_class' => 'new_menu_class' ) ); ?>

Again, replace additional-menu with the menu name you chose. We created 'new_menu_class' 类作为示例,请随意在这里指定您自己的样式类. 不要忘记在样式中为新创建的类添加样式规则.CSS file which is located under /wp-content/themes/your_theme/ directory on the server.

This is it, 你的主题有了一个额外的菜单,现在你离最伟大的网站又近了一步. Stay tuned!


超级菜单的元素页面建设者WordPress插件

JetMenu is a highly functional plugin, 这是削减元素页面建设者,并允许创建Mega菜单与下拉项目是同时易于使用. 这个插件不会限制你的想象力,有丰富的潜力,可以根据你的愿景和需求创建令人惊讶的菜单和样式.

Demo | Download


Stratum - Elementor Extras WordPress Plugin

Stratum Elementor Addon is a collection of 20+ advanced Elementor widgets with a strong business orientation. 该插件增强了现有的element小部件集合的功能,为各种网站提供了额外的多用途元素-从个人作品集和博客到商业网站和大型电子商务项目.

尽管地层小部件与付费解决方案相当,即使是Elementor Pro插件用户也可以免费试用所有20多个插件. Moreover, 该插件提供了访问独家和高要求的选项不可用,甚至在元素Pro包.

Demo | Download



WordPress Add Menu Location FAQ

How to add WordPress menu location?

Under Menu settings>Display location, 你还可以找到一个选项来决定你的菜单在你的WordPress网站上显示的位置. These settings may vary depending on a WordPress theme.

How to add WordPress menu location and customize it?

添加wordpress菜单位置或自定义您网站的默认菜单, you have to enter the WordPress dashboard, click on Appearance and then on Menus.

什么是最好的拖放页面构建器为您的WordPress网站?

我们建议您使用elements页面构建器来拖放自定义您的WordPress主题或现成的网站. There is a growing number of themes, templates, 以及与element市场上提供的页面构建器兼容的插件.

How do I add new features to WordPress?

你可以用插件给你的WordPress网站添加很多功能和工具. A WordPress plugin is essentially an add-on for your website. 插件通常会为你的WordPress网站添加新的特性或功能,而你几乎不需要付出任何努力. Just install and configure the plugin settings.


Read Also


Don’t miss out these all-time favourites

  1. The best hosting for a WordPress website. Tap our link to get the best price on the market with 82% off. If HostPapa didn’t impress you check out other alternatives.
  2. Website Installation service -让您的模板启动和运行在短短6小时内没有麻烦. No minute is wasted and the work is going.
  3. ONE Membership - to download unlimited number of WordPress themes, plugins, ppt and other products within one license. Since bigger is always better.
  4. Ready-to-Use Website service 最终的解决方案是否包含完整的模板安装 & configuration, content integration, implementation of must-have plugins, security features and Extended on-page SEO optimization. A team of developers will do all the work for you.
  5. Must-Have WordPress Plugins -获得最重要的插件为您的网站在一个捆绑包. 所有插件将被安装、激活并检查是否正常运行. 
  6. Finest Stock Images for Websites - to create amazing visuals. You’ll get access to Depositphotos.Com选择15张无限制主题和大小选择的图片.
  7. SSL Certificate Creation service - to get the absolute trust of your website visitors. Comodo证书是最可靠的http协议,确保用户数据安全,免受网络攻击. 
  8. Website speed optimization service -增加您的网站的用户体验,并获得更好的谷歌PageSpeed得分.


Alex Bulat

写一篇博客文章或建立一个小众WordPress网站是Alex可以赤手空拳做的事情. You're welcome to contact him via Telegram, Facebook, or LinkedIn.

Get more to your email

订阅我们的时事通讯和访问独家内容和提供只提供给og体育首页Post订户.

From was successfully send!
Server error. Please, try again later.

Leave a Reply