Created
May 2, 2022 22:26
-
-
Save odil-io/c1cea0799ec46ec02eb0608598d4a807 to your computer and use it in GitHub Desktop.
WP: get sub menu item from specific menu location.
This file contains hidden or 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 | |
$items = wp_get_nav_menu_items( 'top' ); | |
if ( $items ) { | |
echo '<ul class="menu">'; | |
foreach ( $items as $index => $item ) { | |
if ( ! empty( $item->menu_item_parent ) ) { | |
echo '<li class="menu-item' . implode( ' ', $item->classes ) . '">'; | |
echo '<a href="' . $item->url . '" aria-current="page">'; | |
echo $item->title;echo '</a>'; | |
echo '</li>'; | |
} | |
} | |
echo '</ul>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment