Using WordPress ‘network_edit_site_nav_links’ PHP filter

The network_edit_site_nav_links WordPress PHP filter allows you to modify the links that appear on site-editing network pages.

Usage

add_filter('network_edit_site_nav_links', 'your_custom_function');
function your_custom_function($links) {
  // your custom code here
  return $links;
}

Parameters

  • $links (array) – An array of link data representing individual network admin pages.
    • link_slug (array) – An array of information about the individual link to a page.
      • $label (string) – Label to use for the link.
      • $url (string) – URL, relative to network_admin_url(), to use for the link.
      • $cap (string) – Capability required to see the link.

More information

See WordPress Developer Resources: network_edit_site_nav_links

Examples

This example adds a new link to the site-editing network page with the label “Custom Link” and a URL to the custom page.

add_filter('network_edit_site_nav_links', 'add_custom_link');
function add_custom_link($links) {
  $links['custom-link'] = array(
    'label' => __('Custom Link'),
    'url' => 'your-custom-page.php',
    'cap' => 'manage_options'
  );
  return $links;
}

This example removes the ‘site-themes’ link from the site-editing network page.

add_filter('network_edit_site_nav_links', 'remove_site_themes_link');
function remove_site_themes_link($links) {
  unset($links['site-themes']);
  return $links;
}

This example changes the label of the ‘site-info’ link to “Site Information”.

add_filter('network_edit_site_nav_links', 'change_site_info_label');
function change_site_info_label($links) {
  $links['site-info']['label'] = __('Site Information');
  return $links;
}

This example changes the capability required to see the ‘site-settings’ link to ‘manage_network’.

add_filter('network_edit_site_nav_links', 'change_site_settings_capability');
function change_site_settings_capability($links) {
  $links['site-settings']['cap'] = 'manage_network';
  return $links;
}

This example rearranges the order of the links by moving the ‘site-themes’ link to the end.

add_filter('network_edit_site_nav_links', 'rearrange_links');
function rearrange_links($links) {
  $site_themes = $links['site-themes'];
  unset($links['site-themes']);
  $links['site-themes'] = $site_themes;
  return $links;
}