Support » Plugin: Advanced Custom Fields: Nav Menu Field » Add custom ul class

  • 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'
    <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>
    do_action('acf/create_field', array(
    'type'    =>    'text',
    'name'    =>    'fields['.$key.'][ul_class]',
    'value'    =>    $field['ul_class'],
    <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.]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Faison


    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.


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

    Plugin Author Faison


    Hi HansAnderson,

    That was one long week πŸ˜› , 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).


    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?


    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 πŸ˜‰

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add custom ul class’ is closed to new replies.