0

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');

1 Answer 1

1

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

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.