WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm getting this error every time I add an item (page, post or category) to my menu system:

Warning: Invalid argument supplied for foreach() in /home/rootname/public_html/wp-admin/includes/plugin.php line 1261

I also can't insert links to internal pages from within the WYSIWYG editor (no pagesappear in the list).

I guess it could be a theme-server conflict issue as I have an identical set up (same theme, plugins etc) on my localhost which is working ok, it's just the live site that is having issues...

Any ideas of what I should do?




Ok, I've found the root of the problem - it's to do with a function in my functions.php file:

/* Remove admin end options */
add_action( 'admin_init', 'osu_remove_menu_pages' );
function osu_remove_menu_pages() {
    remove_submenu_page('themes.php', 'themes.php');
    remove_submenu_page('themes.php', 'widgets.php');
    remove_submenu_page('plugins.php', 'plugin-editor.php');
    remove_submenu_page('users.php', 'user-role-editor.php');
    // remove_submenu_page('index.php', 'update-core.php');

I'm using it to remove some options on the admin end and would prefer to keep this function if possible just to make the admin end less cluttered. Can anyone see why that might be conflicting with the link system in WP 3.2.1?


share|improve this question
up vote 2 down vote accepted

i also had this problem. the problem is that you are adding action to *admin_init* ... try something like this:

add_action( 'admin_menu', 'remove_unused_menus' );
function remove_unused_menus() {

notice the use of *admin_menu* instead of *admin_init* some require admin_init...but i forget which/why.

share|improve this answer
Thanks @bristweb, that seemed to sort it for me too. I'll read up on which ones need admin_init – Osu Sep 25 '11 at 11:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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