Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom classes for WpMenuItems don't show up #34

Open
drewbaker opened this issue Aug 11, 2018 · 2 comments
Open

Custom classes for WpMenuItems don't show up #34

drewbaker opened this issue Aug 11, 2018 · 2 comments

Comments

@drewbaker
Copy link
Member

If I try to add the category ID of a menu item as a menu item class, it doesn't end up on the final menu item.

This doesn't work:

     function add_dev_id_to_nav_items($nav_item_data){


         if ( isset($nav_item_data['id']) ) {
             // get full nav item
             $object_type = get_post_meta($nav_item_data['id'], '_menu_item_object', true);
             $object_id = get_post_meta($nav_item_data['id'], '_menu_item_object_id', true);

             if ( $object_type == 'category' ) {
                 $nav_item_data['classes'][] = 'category-id-'.$object_id;
             }

             //var_dump($nav_item_data); die;
         }

         return $nav_item_data;
     }
     add_filter('rez_serialize_nav_item', 'add_dev_id_to_nav_items');
@SaFrMo
Copy link
Contributor

SaFrMo commented Oct 30, 2018

@drewbaker Are you still running into this issue? Just checking before diving in - at first glance, we might have found a Vue-ier way of doing it since then. Thanks!

@drewbaker
Copy link
Member Author

Yeah this was on Story Attic, the last site I built. Would love to improve the menus, always seems finicky and manual to get the right classes on them (specially when it comes to News, categories or blog posts).

@SaFrMo SaFrMo transferred this issue from funkhaus/fh-components Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants