Linux 软件免费装
Banner图

Advanced Custom Fields: Nav Menu Field

开发者 Faison
更新时间 2014年10月15日 13:33
PHP版本: 3.4 及以上
WordPress版本: 4.0
版权: GPL2 or later
版权网址: 版权信息

标签

menu admin navigation custom fields acf Advanced Custom Fields nav menu acf4 acf5

下载

1.1.0 1.1.1 1.1.2 2.0.0 1.0.0

详情介绍:

Add Navigation Menus to Advanced Custom Fields (ACF) with the Nav Menu Field plugin! This plugin adds the Nav Menu Field type to ACF (version 5 & 4), allowing you to select from the menus you create in the WordPress Admin backend to use on your website's frontend. Using ACF, you can set the Nav Menu Field to return the selected menu's: I created this plugin because I needed to display a secondary menu that changed depending on what page you're on. Most of those pages were children of the same page, but then I had to throw a couple of Custom Post Types in there too. Because of the Custom Post Types, I couldn't just grab the top most parent for the current page and use wp_list_pages. So I did some research and decided to extend the functionality of my favourite plugin, Advanced Custom Fields. Now when I create a new Page or Custom Post, I just select the menu from a drop down menu! Feel free to try this add-on on your dev site, ask questions on the support link above, and please review this add-on. By leaving a rating and review, you help this plugin become even better! Advanced Custom Fields Compatibility This add-on will work with:

安装:

Follow the following instructions: https://codex.wordpress.org/Managing_Plugins#Installing_Plugins

屏幕截图:

  • Adding the Nav Menu Field to an Advanced Custom Fields Field Group
  • Creating your menu in the WordPress Admin backend
  • Selecting the previously created menu in the meta box created by Advanced Custom Fields
  • Viewing the (not styled) menu displayed by calling 'the_field()' in the sidebar

升级注意事项:

2.0.0 You now have support for ACF v5, and when the code is read, it makes fewer people cry! 1.1.1 I forgot to add a default value for the Menu Container field. So to eliminate WP_DEBUG warnings, I added 'div' as the default value. Please upgrade to avoid the warnings. 1.1.0 Added a new minor feature for selecting the Menu's containing element. 1.0.0 If you have a version less than 0.1.0, something went really, really wrong. Upgrade now, because I have no idea what will happen if you don't!

常见问题:

Can you show a quick example of how to use this?

Sure can!

  1. Create a new field group
  2. Add a Nav Menu and set the Field Label to Side Menu (this will cause the Field Name to be side_menu)
  3. Set the Nav Menu's Return Value to Nav Menu HTML
  4. Set the Location Rules to Show if "Post Type" "is equal to" "Page"
  5. Save the Field Group
  6. Now in your themes sidebar.php, put the following code before or after any of the div's with class="widget-area" `
` Finally, create or edit a page, select a menu in the Side Menu field, and view the page to see that menu in the sidebar!

Will you make this plugin compatible with Advanced Custom Fields v3?

No.

Why does the Nav Menu returned by your plugin look like an unstyled list of links?

So that you can style it yourself. I don't want to step on your toes :)

I added the Nav Menu Field to Pages, selected my menu when creating a new page, but the menu doesn't show. What gives?

First, check that you added the necessary ACF code to your templates. If you don't know what I'm talking about, read up on how to use Advanced Custom Fields. If you're already familiar with ACF and you still can't figure out why the menu isn't showing up, start a new support thread, include details and a little code, and I'll do my best to help you.

更新日志:

2.0.0 1.1.2 1.1.1 1.1.0 1.0.0