Example:
PHP
$menus = wp_get_nav_menus();
foreach ( $menus as $menu /** @var WP_Term $menu */ ) {
echo '<h2>' . $menu->name . '</h2>';
$menu_items = wp_get_nav_menu_items( $menu->term_id );
if ( ! empty( $menu_items ) ) {
echo '<ul>';
foreach ( $menu_items as $menu_item ) {
echo '<li><a href="' . $menu_item->url . '">' . $menu_item->title . '</a></li>';
}
echo '</ul>';
}
}
How to get Wordpress Menu in PHP | Wordpress Menu Tutorial |
Read Full: | Wordpress Menu Tutorial |
Category: | Web Tutorial |
Sub Category: | Wordpress Menu Tutorial |
Uploaded: | 1 month ago |
Uploaded by: | Admin |
Views: | 13 |