2

I'm trying to come up with a solution that would allow me to remove the default post types (pages, posts, comments, links, etc) from all the multi-site blogs EXECEPT the primary blog. It will remain fully functional. My purpose is to apply a custom post type to all the multi-site blogs to replace the defaults.

Any help in the right direction would be much appreciated.

-Phil

2 Answers 2

0

I don't use Multisite much, but I believe something like this might work:

If I'm not mistaken, global $blog_id; lets you access the various "Blogs" ids. Then, the "Main Blog" should have an ID of 1.

So, removing the post type menus from all blogs that DO NOT have the id of 1 would go something like this:

<?php 

function remove_menus() {    

    global $blog_id, $menu;

    if( $blog_id != '1' ) {

        $restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));

        end ($menu);    

        while (prev($menu)){
    $value = explode(' ',$menu[key($menu)][0]);
    if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
    }

    }
} 
?>

add_action('admin_menu', 'remove_menus');

This is where I got the Remove Menus function:

http://www.wprecipes.com/how-to-remove-menus-in-wordpress-dashboard

Note: This hasn't been tested. Just a theory. . .I don't use multisite often and don't have one set up to try this on at the moment.

1
  • I ran accross the same post after I posted this and I was able to remove the menus which removes the post types as well. Thanks!
    – krazymatty
    Jan 27, 2012 at 16:28
0

Since WP 3.1.0 you can use remove_menu_page. Example:

  add_action('admin_menu', function() {
    if (!is_main_site()) return;
    remove_menu_page('edit.php?post_type=post');
    remove_menu_page('edit.php?post_type=page');
  });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.