diff --git a/includes/navwalker.php b/includes/navwalker.php
index 78865ae..a3cd02e 100644
--- a/includes/navwalker.php
+++ b/includes/navwalker.php
@@ -7,11 +7,21 @@
function wrap_parent_menu_item_buttons($output, $item, $depth, $args)
{
// #### MENU HOMEGRADE HEADER
- if ($args->theme_location === "secondary" && in_array('menu-item-has-children', $item->classes, true)) {
-
+ if ($args->theme_location === "secondary" && in_array('menu-item-has-children', $item->classes, true)) {
$output = '';
}
+ if ($args->theme_location === "primary" && in_array('menu-item-has-children', $item->classes, true)) {
+ $page_icon = get_field('page_icon', $item->object_id) ?? null;
+ $icon = isset($page_icon) && is_array($page_icon) && !empty($page_icon['url']) ? '
' : '';
+ $output = '';
+ }
+ // write_log($item->classes);
+ if ($args->theme_location === "primary" && !in_array('menu-item-has-children', $item->classes, true)) {
+ $page_icon = get_field('page_icon', $item->object_id) ?? null;
+ $icon = isset($page_icon) && is_array($page_icon) && !empty($page_icon['url']) ? '
' : '';
+ $output = '' . $icon . $item->title . '';
+ }
return $output;
}
add_filter('walker_nav_menu_start_el', 'wrap_parent_menu_item_buttons', 10, 4);
diff --git a/includes/nawalker_fction.php b/includes/nawalker_fction.php
index 1882ea1..2fa9795 100644
--- a/includes/nawalker_fction.php
+++ b/includes/nawalker_fction.php
@@ -7,9 +7,11 @@
function carhop_wrap_parent_menu_item_buttons($output, $item, $depth, $args)
{
if ($args->theme_location === "primary") {
- $page_icon = get_field('page_icon', $item->object_id);
+ $page_icon = get_field('page_icon', $item->object_id) ?? null;
+ // $test = get_field('page_icon', 729);
+ // write_log($test);
- if (isset($page_icon)) {
+ if (isset($page_icon) && is_array($page_icon) && !empty($page_icon['url'])) {
$icon = '
';
// Insérer l'icône à l'intérieur du lien (seulement la première occurrence)
$output = preg_replace('/>/', '>' . $icon, $output, 1);