Shared Navigation in WordPress MU

I am working on my first serious WordPress MU installation in a couple of years, and I came across an interesting question:  How do I use the main home page navigation across all blogs?  Basically, I need the main navigation to be the same on every blog.

After some research, I came upon this discussion thread on the WordPress forums.  In the thread, you will see all sorts of different solutions proposed from plugins to hooks.  The simplest solution that I found is to include the following in your sub-blog’s “header.php” file:

<?php switch_to_blog(1); ?>
<?php wp_list_pages('title_li='); ?>
<?php restore_current_blog(); ?>

This code temporarily switches back to the main blog’s information, pulls the main navigation, then switches back to the current blog.  Pretty nifty!

Posted in ,

2 Comments

  1. Carl on September 18, 2009 at 8:32 pm

    Wow. That function could open up a number of possibilities for cross blog sharing. Good tool for the toolbox.

    I was actually trying to find a way to do that on an install recently (without hard coding the page urls)

    Thanks



  2. Toby on September 21, 2009 at 8:58 pm

    @Carl – Glad to be of service. 🙂



RSS From Toby’s Blog

  • “Now THAT was a good meeting!”
    A single effective meeting can change the course of history for a company. Imagine if you could lead effective meetings EVERY DAY! You can, but it takes curiosity & practice. This article is a good place to start your journey to a more effective you.
  • Never Respond to RFPs & Custom Proposal Requests
    Y'all who work at normal 9-5 jobs don't need to deal with the B.S. that is an RFP process (or rather you get paid to deal with it). But us freelancers gotta deal with a whole big bag of schtuff when it comes to custom proposals. Here's my quick-and-dirty RFP filtering process that I use […]
  • What content should I put on my homepage?
    I see websites as one stop of many on the sales journey, useful to help get customers from Point A to Point B in the sales process (or maybe from Point D to Point E).  If you are wondering about what to put on your homepage, start with these basic sales-related questions: Who, specifically, will…

More posts from themightymo.com

woocommerce logo

How to fix the “Warning: Class ‘Automattic\WooCommerce\StoreApi\Routes” issue in WordPress + WooCommerce

By The Mighty Mo! Design Co. | May 13, 2022

Today when I visited a customer’s website, I saw an error similar to this: etc. After trying all sorts of troubleshooting, the solution ended up being simple. Download a fresh copy of WooCommerce from WordPress.org and FTP it up to the server, replacing the existing WooCommerce files. Problem solved. Isn’t that nice? Many thanks to…

How to CSS rainbow text

By The Mighty Mo! Design Co. | March 31, 2022

Here’s a bit of plain CSS that’ll create rainbow text on your WordPress site or anywhere, really.

How to Restore a Deleted Amazon S3 Bucket

By The Mighty Mo! Design Co. | March 22, 2022

I ran into a rather serious issue recently: a human on my team (me) intentionally (but accidentally) deleted an Amazon S3 bucket that was serving files to a WordPress site. The solution to the problem follows: Cry when you realize you cannot restore a deleted S3 bucket. Search your computer, your co-workers’ computers, your former…

RSS From Toby’s Blog

  • “Now THAT was a good meeting!”
    A single effective meeting can change the course of history for a company. Imagine if you could lead effective meetings EVERY DAY! You can, but it takes curiosity & practice. This article is a good place to start your journey to a more effective you.
  • Never Respond to RFPs & Custom Proposal Requests
    Y'all who work at normal 9-5 jobs don't need to deal with the B.S. that is an RFP process (or rather you get paid to deal with it). But us freelancers gotta deal with a whole big bag of schtuff when it comes to custom proposals. Here's my quick-and-dirty RFP filtering process that I use […]
  • What content should I put on my homepage?
    I see websites as one stop of many on the sales journey, useful to help get customers from Point A to Point B in the sales process (or maybe from Point D to Point E).  If you are wondering about what to put on your homepage, start with these basic sales-related questions: Who, specifically, will…