<?php

$menu_location = 'socials';
$locations = get_nav_menu_locations();
$menu_id = $locations[$menu_location];
$menu_items = wp_get_nav_menu_items($menu_id);
$micro_links = '';

foreach ($menu_items ?? [] as $menu_item) {
    $icon = get_field('icon', $menu_item); // Получаем URL иконки из ACF
    $title = $menu_item->title;
    $url = $menu_item->url;

    $micro_links .= '<link itemprop="sameAs" content="' . esc_url($url) . '">';

    echo "<a href='" . esc_url($url) . "' class='social-link' target='_blank'>";
    if (!empty($icon)) {
        echo "<img src='" . esc_url($icon) . "' alt='" . esc_attr($title) . "' />";
    }
    echo "</a>";
}
?>

