WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields: Nav Menu Field
Add custom ul class (5 posts)

  1. HansAnderson
    Member
    Posted 1 year ago #

    Nice plugin! It seems useful to have an easy place to set the ul class. The needed changes to the plugin are below (pre-existing code is in italics, to give context).

    <em>$this->defaults = array(
    'save_format' => 'id',
    'allow_null' => 0,</em>
    'ul_class' => 'menu',
    <em>'container' => 'div'
    );</em>
    <tr class="field_option field_option_<?php echo $this->name; ?>">
    <td class="label">
    <label><?php _e("ul class",'acf'); ?></label>
    <p class="description">Class for Menu's ul</p>
    </td>
    <td>
    <?php
    do_action('acf/create_field', array(
    'type'    =>    'text',
    'name'    =>    'fields['.$key.'][ul_class]',
    'value'    =>    $field['ul_class'],
    ));
    ?>
    </td>
    </tr>
    <em>wp_nav_menu( array(
    'menu' => $value,
    'container' => $field['container'],</em>
    'menu_class' => $field['ul_class']
    <em>) );</em>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

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

  2. Faison
    Member
    Plugin Author

    Posted 1 year ago #

    Hi HansAnderson,

    I considered adding the other wp_nav_menu arguments as options in ACF, but wondered if anyone would even find them useful. So thank you for voicing your interest, I'll have an update out before the end of the week.

    Thanks,
    Faison

    P.S. Don't forget to leave a review and a rating!

  3. Faison
    Member
    Plugin Author

    Posted 10 months ago #

    Hi HansAnderson,

    That was one long week :P , on a serious note though, I added your code to the plugin (with some modifications). I felt it made more sense to call the option "Menu Class" in order to follow the same naming convention that wp_nav_menu uses.

    I'll be putting out a 1.2.0 update with the changes soon, but first I want to look into only showing that option (as well as other wp_nav_menu args options) only when a user clicks "More Options" (or something similar).

    Thanks,
    Faison

  4. Dademaru
    Member
    Posted 8 months ago #

    Hi Faison,
    thanks for your great plugin, which makes even more essential the ACF plugin!

    Any update about the possibility to customize the ul class?
    Thanks,
    Davide

  5. Dademaru
    Member
    Posted 8 months ago #

    Hi,

    I found the solution:
    set return value: “Nav Menu ID” then use wp_nav_menu( $args ); and add your class to 'items_wrap'.
    So Faison doesn't need to apply any change to his great plugin ;-)
    cheers
    Davide

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags