Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // All sub-site drop down display
- if (!function_exists('get_all_multisite_links')) {
- function get_all_multisite_links($menu_name = 'Primary')
- {
- global $blog_id;
- $current_blog_id = $blog_id; // Get current blog id
- switch_to_blog(1); // change blog to 'parent site' (ID = 1)
- $primaryNav = wp_get_nav_menu_items($menu_name);
- $menu_object = wp_get_nav_menu_object($menu_name);
- ?>
- <h2 class="widget-title mb-3">
- <?php
- echo $menu_object->name;
- ?>
- </h2>
- <div class="selectDesti position-relative">
- <select id="select" class="custom-select">
- <?php
- echo '<option value="">--' . $menu_object->name . '--</option>';
- foreach ($primaryNav as $navItem) { ?>
- <option value="<?php echo $navItem->url; ?>"><?php echo $navItem->title; ?></option>
- <?php }
- switch_to_blog($current_blog_id); // re-assign current blog value
- ?>
- </select>
- </div>
- <script>
- jQuery(document).ready(function() {
- jQuery('#select').change(function() {
- location.href = jQuery(this).val();
- });
- });
- </script>
- <?php
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement