0

I've set up some admin pages using add_sub_menu() and whenever I add an additional querystring variable beyond the "page=" portion of the URL, I get a "Cannot load 'page-slug'." message. When I remove the every variable the page loads correctly. Here is my add menu code:

add_submenu_page(
  'plugin-slug',
  __( 'Post Types - Add', 'plugin-slug' ),
  null,
  'manage_options',
  'plugin-slug-posttypes-add',
  'display_admin_page_posttype_add'
);

If I browse to:

/wp-admin/admin.php?page=plugin-slug-posttypes-add

it works fine. But browsing to:

/wp-admin/admin.php?page=plugin-slug-posttypes-add&post_type=sampletype

returns:

Cannot load content-toolkit-posttypes-add.

0

You're recieving this error because WordPress notices the post_type query argument and that sampletype is a valid registered post type, and thinks you're on an edit page. Try using a different query arg then post_type.

Note that admin.php?page=plugin-slug-posttypes-add&post_type=thisisnotaposttype and admin.php?page=plugin-slug-posttypes-add&foo=bar will both work fine.

  • I didn't realize using that specific variable name would affect it. Thanks! – hereswhatidid Jun 15 '13 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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