Skip to content

Instantly share code, notes, and snippets.

@stevecordle
Created July 9, 2015 14:58
Show Gist options
  • Save stevecordle/897361a8a8c453ff1591 to your computer and use it in GitHub Desktop.
Save stevecordle/897361a8a8c453ff1591 to your computer and use it in GitHub Desktop.
Adding a Marketing Tips menu Item to every site on Wordpress MU network
$site_args = array(
'network_id' => $wpdb->siteid,
'public' => null,
'archived' => null,
'mature' => null,
'spam' => null,
'deleted' => null,
'limit' => 1000,
'offset' => 0
);
$siteList = wp_get_sites($site_args);
foreach($siteList as $site){
switch_to_blog( $site['blog_id'] );
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_items('main-menu');
foreach($menu as $item){
if($item->post_name == 'resources'){
$resources_ID = $item->ID;
$tips = wp_update_nav_menu_item($locations['main-menu'], 0, array(
'menu-item-title' => __('Marketing Tips'),
'menu-item-classes' => 'tips',
'menu-item-url' => '/resources/tips/',
'menu-item-status' => 'publish',
'menu-item-parent-id' => $resources_ID
));
}
}
restore_current_blog();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment