• Resolved Andi Lee Davis

    (@andi-lee-davis)


    hi there,

    Yep can agree this plugin crashes the theme.

    Pasting this in your themes functions.php doesn;t cut the mustard.

    function my_register_fields()
    {
        include_once('advanced-custom-fields-nav-menu-field/nav-menu-v4.php');
    }
    add_action('acf/register_fields', 'my_register_fields');

    Instead you NEED TO INCLUDE the directory of you plugins…
    This will resolve it.

    function my_register_fields()
    {
        include_once(WP_PLUGIN_DIR . '/advanced-custom-fields-nav-menu-field/nav-menu-v4.php');
    }
    add_action('acf/register_fields', 'my_register_fields');

    https://wordpress.org/plugins/advanced-custom-fields-nav-menu-field/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    At first I thought this was a standalone plugin but its not. It needs the advanced post types plugin to be available first. This is just a handy extension, but the description on the install page doesn’t say this.

    I gather that this was supposed to be added to the functions file in the advanced fields plugins (not this one)… so by doing it this way you can now add this code to your function.php inside your theme and be able to upgrade either plugins when you need to without having to re-paste this in.

    Thanks

    Andi

    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    … Actually now i got it working I cannot see the location how to add a custom field to a menu… I want to make a selection and data in a menu to be <a href=”” data-filter=””… or <a href=”” data-expand=””

    By using custom fields applied to my menu’s I was hoping to achieve that but all I can see is how they interact with pages and posts.

    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    sorry I found it. But I also wanted to have a drop down attached to the menu in the admin section to chose

    data-filter
    data-expand

    Then the value of that item

    x

    so in the nav you get:

    <li class="page_item selected" ><a href="/" data-filter="*" ><span>wpb</span></a></li>
                <li class="page_item" ><a href="/#case-study" data-filter=".case-study" ><span>our work</span></a></li>
                <li class="page_item" ><a href="/#about-wpb" data-expand=".about-wpb" ><span>about us</span></a></li>

    Is this possible?

    thanks

    Andi

    Plugin Author Faison

    (@faison)

    Hi Andi Lee Davis,

    Sorry for the late response. The installation instructions were pulled in directly from the plugin template that the developer of ACF provides, and since this was my first plugin, I didn’t know if that should still be valid.

    I’ve just updated the plugin (currently just on github) and the installation instructions will be much more clear. Basically make sure you have ACF installed, then install this plugin through the plugin installer.

    So sorry for that confusion.

    Regarding your question about adding data-filter and data-expand: Assuming you haven’t figured out a way to do that in one way or another, the best way to manage that would be through a filter. I don’t have the time to go into too much detail, but it looks like the filter you would need is “nav_menu_link_attributes”. If you google that, look it up in the codex, or even in WordPress core, that could get you started.

    Thanks,
    Faison

    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    Hi there, Yeah I solved it by using the xfn field already in the wrodpress section. Thanks for your information and well done on your plugin.

    Its a long time back but using this variable WP_PLUGIN_DIR resolves that initial issue.

    Thanks

    Andi

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Include the plugins path’ is closed to new replies.