0

So im currently developing a plugin, this plugin has a new CPT that i would like to exclude its menu from the admin page of the first site. Im using a multi-site installation. The menu has to only be visible to the other site admins but not the first one.

The Link where i want to remove the menu from is www.example.com/wp-admin

Thank you!

  • Does the first site need the CPT and only not display the menu? If not, just activate the plugin on the sites you want it and not on those you don't want to – kero Jul 13 '17 at 9:25
  • Exactly friend it needs the CPT but not the menu. – MashRoofa Jul 13 '17 at 9:31
1

When you register the custom post type, you can control whether the menu item appears with the show_in_menu arg. You could do something like the following ( this has not been tested ):

// create a constant to store the ID of the blog where the menu should be hidden.
define('HIDDEN_MENU_BLOG_ID', 1 );

function codex_custom_init() {
    $show_in_menus = ( HIDDEN_MENU_BLOG_ID === get_current_blog_id() ) ? false : true;

    $args = array(
      'public' => true,
      'label'  => 'Books'
      'show_in_menu' => $show_in_menus,
    );
    register_post_type( 'book', $args );
}
add_action( 'init', 'codex_custom_init' );

This is not very scalable however, you may want to couple this with an admin screen where a super-admin can choose which blogs to hide the menu from.

Hope this helps!

0

Wordpress switch to blog function will helps to solve your problem.

  • Can you explain how this helps a bit? – Welcher Jul 13 '17 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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