website stat

How to Register WordPress Multisite Widget Areas For Only the Main Site

If you’re running an installation of WordPress multisite or Buddypress, where the main site has a different look and feel than the network of sites, you’ve likely registered some widget areas that are only necessary for the main site.

The issue, however, is that your network of sites see these widget areas (that they can’t use) in their Widget editor. And if you’ve created a lot of widget areas that their design doesn’t use, you’re likely confusing your users with unnecessary choices.

So if you want to have widget areas available for your main site and not your network, use this easy fix.

In your functions.php file (where you register the widget areas), simply add this line of code:

global $blog_id;
if( $blog_id == ‘1’ ) {

REGISTER YOUR WIDGET AREA HERE

}

And that’s it. You can put as many widget areas in this code block as you want.

If you want to register certain widget areas for your network and not the main site, simply change == ‘1’ to !==’1′.

If you want to register certain widget areas for specific blogs, simply change the blog_id to the ID of the blog where it should appear.

One Comment

  1. Pithecanthropuses

    Hi Jason–

    This post was a huge help to me. Thanks so much for posting it!

Leave a Comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Back

© Jason Unger. A Digital Ink Production.