如何添加WordPress菜单位置[教程]

本指南将向您解释如何 添加WordPress菜单位置 你的主题. Sometimes you may need to add an extra navigation menu with important or frequently used links to increase the usability of your WordPress site.

要创建一个新菜单,您需要编辑您的主题文件. 在更改任何核心文件之前,最好进行以下操作 备份整个站点 以防中途出了什么差错.

To add a new menu location option in your admin dashboard under Appearance > Menus 你需要 “注册菜单”. 所要做的就是向您的 的功能.php' 文件位于 / wp-content /主题/ your_theme / 服务器上的目录.


Hey, you! 你听说我们新的订阅服务了吗 ONE? 如果没有,就继续读我告诉你的! Our new subscription service ONE can give you an awesome opportunity to save your money and to get more items. The subscription costs only $19 a month and gives you access to downloads of any material from ONE package. Just subscribe for ONE and get unlimited quantity of cool elements! 看看什么 WordPress themes we have for you now within the subscription and choose the most appropriate ones. Moreover, 如果你是一个博客读者, you can get a 5% discount on the subscription using the simple promo code BecomeThe1.


注册新的WordPress添加菜单位置

使用以下命令访问服务器 ftp客户端 or 文件管理 由你的主人提供. 导航到 / wp-content /主题/ your_theme / 服务器上的目录. Open the 的功能.php' 要编辑的文件.

如何添加菜单wordpress

滚动到文件的底部. If you'd like to add only one menu, add the following code on a new line:

函数register_my_menu() {
register_nav_menu(“额外的菜单”,__( “额外的菜单” ));
}
Add_action ('init', 'register_my_menu');

在这个例子中, “额外的菜单” is the name that will appear in your admin dashboard's menu page. The “额外的菜单” 名字是什么? WordPress 能理解正确执行代码吗.

If you would like to add multiple menus to your site, add this code on a new line instead:

函数register_my_menus() {
register_nav_menus (
array(
 “额外的菜单” => __( “额外的菜单” ),
 'another-menu' => __( 'Another Menu' ),
 'extra-menu' => __( 'Extra Menu' )
 )
 );
}
Add_action ('init', 'register_my_menus');

您可以使用此方法添加任意多的新菜单. 命名它们时也适用相同的规则. Save 您对文件所做的更改.


通过仪表板创建新的WordPress添加菜单位置

转到 Appearance > Menus 在你的仪表盘上. You'll notice your new menus will be listed under Theme Locations in the 管理位置 section.

添加导航菜单

请随意 创建一个新菜单 或者使用现有的. 一旦你创建了一个新的菜单, you can also manage the locations where they are displayed under the '管理位置s' tab.

添加导航菜单

WordPress添加菜单位置到您的主题

This is where 你需要 decide where you'd like to place your menu. If you'd like your menu to appear at the top of your page, you'll need to edit the 'header.php' file. You can also put it in your footer which means you would edit the 'footer.php' file. You can even display a menu on a page by editing its template file or to a sidebar, editing its 'sidebar.php' file.

你可以把你的新菜单放在任何你喜欢的地方. Here's the minimum amount of code 你需要 add to any of these locations:

 “额外的菜单” ) ); ?>

Where 额外的菜单 你的新菜单是.

You probably want to style your menu with CSS so it goes beyond basic functionality and also looks great. To do this, you'll need to create a class and add it 你的主题 with the following code:

 “额外的菜单”, 'container_class' => “new_menu_class” ) ); ?>

再次,取代 额外的菜单 使用您选择的菜单名称. 我们创建了 “new_menu_class” class as an example, feel free to specify your own style class here. Do not forget to add style rules for the new created class in your style.CSS文件位于 / wp-content /主题/ your_theme / 服务器上的目录.

就是这个了, your theme got an additional menu and now you are one step closer to the greatest site ever. 请继续关注!


JetMenu - Mega Menu for Elementor Page Builder WordPress Plugin

JetMenu是一个功能强大的插件, which was cut for Elementor page builder and allows to create Mega menus with dropdown items being at the same time easy to use. This plugin doesn’t limit your imagination and has rich potential of creating astonishing menus and styling them according to your vision and needs.

Demo | Download


Stratum -元素额外的WordPress插件

地层元素插件是一个集合 20+高级元素小部件 强烈的商业导向. The addon enhances the functionality of the existing Elementor widgets collection with extra multipurpose elements for all kinds of websites - from personal portfolios and blogs to business websites and large eCommerce projects.

Although Stratum widgets are fairly equal to premium-like solutions,even Elementor Pro the addon users can try all 20+ widgets for free. Moreover, the addon gives access to exclusive and highly-demanded options unavailable even in the Elementor Pro packages.

Demo | Download



WordPress添加菜单位置常见问题

如何添加WordPress菜单位置?

Under Menu settings>Display location, you also find the option to determine where you want your menu to show on your WordPress website. 这些设置可能因WordPress主题而异.

如何添加WordPress菜单位置和自定义它?

To add wordpress menu location or customize the default menu of your website, 你必须进入WordPress仪表板, 点击外观,然后点击菜单.

What's the best drag and drop page builder for your WordPress site?

We recommend you use the Elementor page builder for drag-and-drop customization of your WordPress theme or a ready-to-go website. 主题越来越多, 模板, and plugins compatible with the page builder available in the Elementor marketplace.

如何向WordPress添加新功能?

You can add a lot of features and tools to your WordPress site with plugins. WordPress插件本质上是你网站的一个附加组件. Plugins typically add new features or functionality to your WordPress website with little effort on your part. 只需安装和配置插件设置.


读也


不要错过这些一直以来的最爱

  1. The best hosting 用于WordPress网站. 点击我们的链接,获得市场上最优惠的价格,82%的折扣. 如果HostPapa没有给你留下深刻的印象,看看其他 选择.
  2. 网站安装服务 - to get your template up and running within just 6 hours without hassle. 没有一分钟是浪费的,工作正在进行.
  3. 一个会员 -下载无限数量的WordPress主题, plugins, PPT等产品在一个许可范围内. 因为越大越好.
  4. 现成的网站服务 is the ultimate solution that includes full template installation & 配置, 内容集成, 实现必备插件, 安全功能和扩展的页面SEO优化. 开发团队将为您完成所有工作.
  5. 必备的WordPress插件 - to get the most essential plugins for your website in one bundle. All plugins will be installed, activated and checked for proper functioning. 
  6. 最好的库存图片的网站 -创造惊人的视觉效果. 你可以访问Depositphotos.com to choose 15 images with unlimited topic and size selection.
  7. SSL证书创建服务 -获得网站访问者的绝对信任. Comodo Certificate is the most reliable http protocol that ensures users data safety against cyber attacks. 
  8. 网站速度优化服务 - to increase UX of your site and get a better Google PageSpeed score.


亚历克斯Bulat

Writing a blog post or building a micro niche WordPress website is something Alex can do bare-handed. 欢迎您通过 电报, Facebook, or LinkedIn.

在你的电子邮件中添加更多内容

订阅 to our newsletter and access exclusive content and offers available only to og体育首页Post subscribers.

发送成功!
服务器错误. 请稍后再试.