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?


1 Answer 1


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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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