add_submenu_page() issue

I am trying to add a Menu in WordPress Admin Panel. I am using below code.

This code is working.

add_submenu_page('weather_info', 'Weather Information', 'Weathers', 'manage_options', 'weathers', [$this, 'weathers']);

But below code is not working. I am facing error Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'edit.php?post_type=weather' not found or invalid function name .

add_submenu_page('weather_info', 'Weather Information', 'Weathers', 'manage_options', 'weathers', 'edit.php?post_type=weather');

Topic add-submenu-page wp-admin Wordpress

Category Web


edit.php?post_type=weather isn't a valid PHP function name.

If you're trying to set the menu up as a submenu of your custom post screens, I think edit.php?post_type=weather—the $parent_slug—should be the first parameter, not the last. ie,

add_submenu_page(
  'edit.php?post_type=weather',
  'Weather Information',
  'Weathers',
  'manage_options',
  'weathers',
  [$this, 'weathers']
);

References

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.