Last active
November 7, 2021 10:13
-
-
Save dhimaskirana/9a2e869a876b79b7b67582809aa72b6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('nav_menu_css_class', 'tambah_class_pada_li', 1, 3); | |
function tambah_class_pada_li($classes, $item, $args) { | |
// Kondisional jika class li tag berbeda pada lokasi menu yang berbeda | |
if ($args->theme_location == 'menu-footer') { | |
$classes[] = 'list-inline-item'; | |
} else { | |
$classes[] = 'nav-item'; | |
} | |
// Kondisional jika halaman yang aktif diberi class | |
if (in_array('current-menu-item', $classes)) { | |
$classes[] = 'active '; | |
} | |
// Kembalikan class yang sudah di modifikasi | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment