Guest User

Untitled

a guest
Jan 17th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <?php
  2. $count = 0;
  3. $a = 0;
  4. $submenu = false;
  5. foreach( $menuitems as $item ):
  6. $link = $item->url;
  7. $title = $item->title;
  8. // item does not have a parent so menu_item_parent equals 0 (false)
  9. if ( !$item->menu_item_parent ):
  10. // save this id for later comparison with sub-menu items
  11. $parent_id = $item->ID;
  12.  
  13. ?>
  14.  
  15. <li>
  16. <a href="<?php echo $link; ?>" class="title"> <?php echo $title; ?> </a>
  17. <?php endif;
  18.  
  19.  
  20. if ( $parent_id == $item->menu_item_parent ): ?>
  21.  
  22. <?php if ( !$submenu ): $submenu = true;
  23.  
  24. ?>
  25.  
  26. <ul class="rd-navbar-megamenu"> // this class should start if there are 4 items (li)
  27. <?php endif; ?>
  28. <li>
  29. <ul class="rd-megamenu-list">
  30. <li><a href="<?php echo $link; ?>" class="title"><?php echo $item->title; ?></a></li>
  31. </ul>
  32. </li>
  33. <?php
  34.  
  35. if ( $menuitems[ $count + 1 ]->menu_item_parent != $parent_id && $submenu ):
  36.  
  37. if($a % 4 == 0) {
  38. echo '</ul><ul class="rd-navbar-megamenu">';
  39. }
  40. ?>
  41. </ul>
  42.  
  43. <?php $submenu = false; endif;
  44.  
  45. endif;
  46.  
  47. if ( $menuitems[ $count + 1 ]->menu_item_parent != $parent_id ):
  48.  
  49. ?>
  50.  
  51. </li>
  52. <?php $submenu = false; endif;
  53.  
  54. $count++;
  55.  
  56. endforeach;
  57. ?>
Add Comment
Please, Sign In to add comment