Add a link to the Admin menu

时间:2013-10-08 作者:user39156

我想在wordpress admin:Published and Scheduled中的POSTS菜单中添加两行内容。我还想在“媒体”菜单中为未连接的媒体添加一个部分。我该怎么做呢?

干杯enter image description here

1 个回复
最合适的回答,由SO网友:gmazzap 整理而成

您可以拦截全局$submenu var并添加所需的元素:

add_action(\'admin_menu\', \'add_custom_submenus\', 999);

function add_custom_submenus() {
  global $submenu;
  $submenu[\'edit.php\'][] = array(
    __(\'Published\'), // menu title
    \'edit_posts\', // menu cap
    \'edit.php?post_status=publish&post_type=post\' // menu link
  );
  $submenu[\'edit.php\'][] = array(
    __(\'Scheduled\'),
    \'edit_posts\',
    \'edit.php?post_status=future&post_type=post\'
  );
  $submenu[\'upload.php\'][] = array(
    __(\'Unattached\'),
    \'upload_files\',
    \'upload.php?detached=1\'
  );
}

结束