Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $count = 0;
- $a = 0;
- $submenu = false;
- foreach( $menuitems as $item ):
- $link = $item->url;
- $title = $item->title;
- // item does not have a parent so menu_item_parent equals 0 (false)
- if ( !$item->menu_item_parent ):
- // save this id for later comparison with sub-menu items
- $parent_id = $item->ID;
- ?>
- <li>
- <a href="<?php echo $link; ?>" class="title"> <?php echo $title; ?> </a>
- <?php endif;
- if ( $parent_id == $item->menu_item_parent ): ?>
- <?php if ( !$submenu ): $submenu = true;
- ?>
- <ul class="rd-navbar-megamenu"> // this class should start if there are 4 items (li)
- <?php endif; ?>
- <li>
- <ul class="rd-megamenu-list">
- <li><a href="<?php echo $link; ?>" class="title"><?php echo $item->title; ?></a></li>
- </ul>
- </li>
- <?php
- if ( $menuitems[ $count + 1 ]->menu_item_parent != $parent_id && $submenu ):
- if($a % 4 == 0) {
- echo '</ul><ul class="rd-navbar-megamenu">';
- }
- ?>
- </ul>
- <?php $submenu = false; endif;
- endif;
- if ( $menuitems[ $count + 1 ]->menu_item_parent != $parent_id ):
- ?>
- </li>
- <?php $submenu = false; endif;
- $count++;
- endforeach;
- ?>
Add Comment
Please, Sign In to add comment