admin管理员组文章数量:1201788
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');
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');
Share
Improve this question
asked May 31, 2022 at 2:04
FoysalFoysal
4451 gold badge5 silver badges16 bronze badges
1 Answer
Reset to default 1edit.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
add_submenu_page()
本文标签: wp adminaddsubmenupage() issue
版权声明:本文标题:wp admin - add_submenu_page() issue 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738563920a2099771.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论