Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. // All sub-site drop down display
  2. if (!function_exists('get_all_multisite_links')) {
  3. function get_all_multisite_links($menu_name = 'Primary')
  4. {
  5. global $blog_id;
  6. $current_blog_id = $blog_id; // Get current blog id
  7. switch_to_blog(1); // change blog to 'parent site' (ID = 1)
  8. $primaryNav = wp_get_nav_menu_items($menu_name);
  9. $menu_object = wp_get_nav_menu_object($menu_name);
  10. ?>
  11. <h2 class="widget-title mb-3">
  12. <?php
  13. echo $menu_object->name;
  14. ?>
  15. </h2>
  16.  
  17. <div class="selectDesti position-relative">
  18. <select id="select" class="custom-select">
  19. <?php
  20. echo '<option value="">--' . $menu_object->name . '--</option>';
  21. foreach ($primaryNav as $navItem) { ?>
  22.  
  23. <option value="<?php echo $navItem->url; ?>"><?php echo $navItem->title; ?></option>
  24. <?php }
  25. switch_to_blog($current_blog_id); // re-assign current blog value
  26. ?>
  27. </select>
  28. </div>
  29. <script>
  30. jQuery(document).ready(function() {
  31. jQuery('#select').change(function() {
  32. location.href = jQuery(this).val();
  33. });
  34. });
  35. </script>
  36. <?php
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement