-
-
Save kucrut/3804376 to your computer and use it in GitHub Desktop.
For anyone who wonders how to use on the frontend:
add_filter( 'nav_menu_link_attributes', 'my_nav_menu_attribs', 10, 3 );
function my_nav_menu_attribs( $atts, $item, $args ) {
$atts['data-mydata'] = get_post_meta($item->ID, '_menu_item_mydata', true);
return $atts;
}
@kucrut, thanks for sharing!
Does anyone know how to display the additional fields in the menu editor inside Customizer?
@JacobDB: Did you get the checkbox to work? I've managed to convert the fields, but haven't yet been succesful in saving (and retrieving) them to/from the database.
If anyone here - how to add checkbox and/or select input ?
if anyone gets to here, this is now packaged into a library that you can use
How to do when there's two or more fields 'item_tpl', 'item_tpl2', 'item_tpl3'
I got an error when I do this code below.
$new_fields .= str_replace(
array_map(function($key){ return '{' . $key . '}'; }, array_keys($field)),
array_values(array_map('esc_attr', $field)),
self::$options['item_tpl', 'item_tpl2', 'item_tpl3']
);
Please help Thanks!
Hi friends,how to add checkbox and/or select input ?
and how to get values ??
Would you be able to help me figure out how to make this work for a checkbox? Also a trimmed down version for a single field would be awesome (but I can probably figure that out on my own).