N
N
nibbl2015-03-09 18:15:01
User navigation
nibbl, 2015-03-09 18:15:01

How to create custom fields in Wordpress menu?

Hello everyone, now I’m making a menu on wordpress, but I don’t have enough additional fields to describe the menu, for example, to make it clear what you need, I made a menu screen www.screencapture.ru/file/A828C751
How can this be implemented on wordpress, I don’t resort to paid menu plugins.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Evgenievich, 2015-03-09
@banderos120

This can be done with a crutch:

add_filter('wp_setup_nav_menu_item', function($menu_item){
    
    $menu_item->icon = get_post_meta($menu_item->ID, '_menu_icon', true);
    
    return $menu_item;
    
});
add_action('wp_update_nav_menu_item', function($menu_id, $menu_item_db_id, $args){
    
    if(!empty($_REQUEST['menu_icon']) && is_array($_REQUEST['menu_icon'])){
        $icon_value = !empty($_REQUEST['menu_icon'][$menu_item_db_id]) ? $_REQUEST['menu_icon'][$menu_item_db_id] : '';
        update_post_meta($menu_item_db_id, '_menu_icon', $icon_value);
    }
    
}, 10, 3);
add_filter('wp_edit_nav_menu_walker', function(){
    
    return 'Theme_Menu_Admin_Walker';
    
});

class in the comments

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question