• Resolved monkeymynd

    (@monkeymynd)


    Currently, I’m using the default template to play with my first multisite WP. Got everything working well. I just have two questions.

    First, I’d like to add a menu item to all sites to return to the main site. I see the following in the header code:

    <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>

    I just want to add a ‘Return to Main Site’ item…not sure how to do this.

    Also, I would like to add a drop down menu to the main site so that it automatically lists the other sites. Ex. Main menu item ‘Blogs’…and then a list of the other sites. I’m currently using the ‘custom menu’ option to do this, but that would mean the admin of the site would have to add an item each time a new site is added. I’d prefer to just have this happen automatically.

    Here is my test site…it’s the ‘Our Horses’ menu that I would like to create automatically w/o having to use the custom menu option.

    https://safeaxis.com

    Thanks in advance for any help ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • I just want to add a ‘Return to Main Site’ item…not sure how to do this.

    How about a hardcoded link to your main domain just using plain ol’ HTML? ??

    getting a list of sites:
    https://wpmututorials.com/how-to/return-a-list-of-sites-on-the-network/

    Thread Starter monkeymynd

    (@monkeymynd)

    Thank you for your response.

    Yes, that’s what I want to do, just put a hardcoded link in, but how do I incorporate that with the wp_nav_menu call?

    I made the following change:

    <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?><a href="https://safeaxis.com">Return to Main Site</a>

    You can see it here: https://safeaxis.com

    Although it works, it doesn’t have the same styling as the menu, and doesn’t have the hover effect, etc. Also, how would I put a check in to exclude it from showing up on the main site.

    Here’s something I have in my functions.php of a twentyten child theme.

    add_filter('wp_nav_menu_items','ds_nav_menu_items',10,2);
    function ds_nav_menu_items($items,$args) {
    global $current_site, $blog_id;
    	if( $args->theme_location == 'primary' && $blog_id !='1' ) {
    		$addmenu = '<li class="menu-item"><a href="' . network_home_url() . '">' . $current_site->site_name . '</a></li>';
    	return $items.$addmenu;
    	} else {
    	return $items;
    	}
    }
    ?>

    Your addon link needs the following so the css kicks in to give it some style:

    <div class="menu-header">
    	<ul class="menu">
    		<li class="menu-item"><a href="https://safeaxis.com">Return to Main Site</a></li>
    	</ul>
    </div>

    Thread Starter monkeymynd

    (@monkeymynd)

    Thank you David…that’s just what I was looking for!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add static menu item to all sites’ is closed to new replies.