how does wordpress assign class upon mouse click(current-menu-item)?

When I click in top navigation menu and page changes, menu item that I clicked on gets bold as current-menu-item class gets assigned to that particular element.
How does WordPress does this?

Related posts

Leave a Reply

1 comment

  1. It depends on your theme, but you can override it if you like. See the wp_nav_menu codex page. Here you can specify the class for the active menu element.

    $menu_class (string) (optional) CSS class to use for the containing
    div element which forms the default menu, or the ul element when a
    custom menu is configured in the admin interface

    Default: menu

    If you just want to change the styling then you can modify the style.css file in your theme folder.

    If you want the actual code that gets executed then I’m not sure where in the core php files that is handled, but I imagine it is something pretty ordinary. For example,

    if (menu_class is defined) { echo menu_class; }