设法在管理中创建一个自定义菜单区域,但现在想在其中放置两种帖子类型。
它们已经存在-问题和;答案,但无法找到将其菜单链接放入自定义菜单的方法。
add_action(\'admin_menu\', \'mt_add_pages\');
function mt_add_pages() {
add_menu_page(__(\'Competition\',\'comp\'), __(\'Competition\',\'comp\'), \'manage_options\', \'mt-top-level-handle\', \'test_func\', \'\', 5 );
add_submenu_page(\'mt-top-level-handle\', __(\'Answers\',\'comp-answers\'), __(\'Answers\',\'comp-answers\'), \'manage_options\', \'sub-page\', \'test_func2\');
}
function test_func(){
echo 1; // question post_type links
}
function test_func2(){
echo 2; // answer post_type links
}
感谢您的帮助!
SO网友:Jeremy Jared
尝试在函数后添加操作,如下所示:
function mt_add_pages() {
// Add theme options page to the addmin menu
add_menu_page(__(\'Competition\',\'comp\'), __(\'Competition\',\'comp\'), \'manage_options\', \'mt-top-level-handle\', \'test_func\', \'\', 5 );
add_submenu_page(\'mt-top-level-handle\', __(\'Answers\',\'comp-answers\'), __(\'Answers\',\'comp-answers\'), \'manage_options\', \'sub-page\', \'test_func2\');
}
add_action( \'admin_menu\', \'mt_add_pages\' );