<?php
    $menus = wp_get_nav_menus();

    foreach($menus as $item) {
        $menu_id = $item->term_id;

        $menu = wp_get_nav_menu_items($menu_id, array(
            'posts_per_page' => -1,
            'meta_key' => '_menu_item_object_id',
            'meta_value' => get_queried_object_id() // the currently displayed post
        ));

        if(count($menu) > 0){
            break;
        }

    }


    if(count($menu) == 0){//значит произвольные ссылки

        $menu = array();

        $current_url = (filter_input(INPUT_SERVER, 'HTTPS') === 'on' ? "https" : "http") . "://". filter_input(INPUT_SERVER, 'HTTP_HOST').filter_input(INPUT_SERVER, 'REQUEST_URI');

        foreach($menus as $item) {
            $menu_id = $item->term_id;
            $menuss = wp_get_nav_menu_items($menu_id, array(
                'posts_per_page' => -1
            ));


            foreach($menuss as $menuitem){
                $menulink = get_post_meta($menuitem->ID, '_menu_item_url', true);
                if(strlen($menulink) > 2){
                    if(strripos($current_url, $menulink) !== false || strripos($menulink, $current_url) !== false){
                        $menu[0] = $menuitem;
                        break;
                    }
                }
            }

        }

    }

    $className = get_post_meta($menu[0]->ID, '_menu_item_color', true);
    $className = empty($className) ? "black" : $className;
    $title = $menu[0]->title;
?>
<div class="col-12 col-md-6 col-xl-4 float-left">
    <div class="section__title section__title--<?php echo $className; ?> d-block d-md-none mb-3">
        <?php echo $title; ?>
    </div>
</div>