Using WordPress ‘network_edit_site_nav()’ PHP function

The network_edit_site_nav() WordPress PHP function outputs the HTML for a network’s “Edit Site” tabular interface.

Usage

network_edit_site_nav( array( 'blog_id' => $blog_id, 'links' => $links, 'selected' => $selected ) );

Parameters

  • $args (array) Optional: Array or string of Query parameters.
    • blog_id (int) The site ID. Default is the current site.
    • links (array) The tabs to include with (label|url|cap) keys.
    • selected (string) The ID of the selected link. Default: array()

More information

See WordPress Developer Resources: network_edit_site_nav()

Examples

Basic usage of the function

This example creates a simple “Edit Site” interface with two tabs – “General” and “Settings”.

// Set up the parameters for the network_edit_site_nav() function
$args = array(
  'blog_id' => 1, // The site ID
  'links' => array(
    'general' => array(
      'label' => 'General',
      'url' => 'https://example.com/wp-admin/network/site-info.php?id=1',
      'cap' => 'manage_sites'
    ),
    'settings' => array(
      'label' => 'Settings',
      'url' => 'https://example.com/wp-admin/network/site-settings.php?id=1',
      'cap' => 'manage_sites'
    )
  ),
  'selected' => 'general'
);

// Call the function with the specified parameters network_edit_site_nav( $args );

Adding a custom tab

This example demonstrates how to add a custom tab called “Custom Tab” to the “Edit Site” interface.

// Set up the parameters for the network_edit_site_nav() function
$args = array(
  'blog_id' => 1, // The site ID
  'links' => array(
    'general' => array(
      'label' => 'General',
      'url' => 'https://example.com/wp-admin/network/site-info.php?id=1',
      'cap' => 'manage_sites'
    ),
    'settings' => array(
      'label' => 'Settings',
      'url' => 'https://example.com/wp-admin/network/site-settings.php?id=1',
      'cap' => 'manage_sites'
    ),
    'custom_tab' => array(
      'label' => 'Custom Tab',
      'url' => 'https://example.com/wp-admin/network/custom-tab.php?id=1',
      'cap' => 'manage_sites'
    )
  ),
  'selected' => 'general'
);
// Call the function with the specified parameters network_edit_site_nav( $args );