Home › Forums › ACF PRO › ACF Location "Nav Menu" › Reply To: ACF Location "Nav Menu"
Nice plugin, good job @happiness 🙂
Anyway we can use filters like this example:
add_filter('wp_nav_menu_items', 'my_wp_nav_menu_items', 10, 2);
function my_wp_nav_menu_items( $items, $args ) {
$menu = wp_get_nav_menu_object($args->menu);
$menuSlug = $menu->slug;
if ($menuSlug == 'hamburger-menu') {
if (is_user_logged_in()) {
$items .= '<li id="menu-item-logout" class="menu-item menu-item-logout"><a href="'. wp_logout_url(home_url()) .'">LOGOUT</a></li>';
} else {
$items .= '<li id="menu-item-login" class="menu-item menu-item-login"><a href="'. home_url() .'/logowanie">LOG IN</a></li>';
}
}
return $items;
}
This is an answer for related question “How to add items to an ACF Nav Menu?”
Hope it helps for future questions about it.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.