想知道是否可以使用自定义菜单链接显示视频的附件管理列表?
欢迎指点!D
add_action(\'admin_menu\', \'mt_add_pages\');
function mt_add_pages() {
add_menu_page(\'Directors & Showreels\', \'Directors & Showreels\', \'manage_options\', \'dsv_menu\', \'wps_theme_func\',null,2);
$videos_page = add_submenu_page(\'dsv_menu\', __(\'Videos\',\'showreel_videos\'), __(\'Videos\',\'showreel_videos\'), \'edit_posts\', \'sub-page-videos\', \'display_showreel_videos\');
}
function display_showreel_videos(){ ?>
<div class="wrap"><h2>Videos</h2>
<!-- get attachments by mime type ? (upload.php?post_mime_type=video ??) -->
</div><?
}
使用类TT\\u Example\\u List\\u Table扩展了WP\\u List\\u Table,下面的链接提供了帮助。。。看起来不错,但无法使“编辑”或“删除”链接正常工作。
$media_query = new WP_Query(
array(
\'post_type\' => \'attachment\', // get attachments only
\'post_status\' => \'inherit\', // attachments are not \'published\', so set it to inherit
\'posts_per_page\' => -1, // display all
\'post_mime_type\' => \'video\' // grab files with the mime type \'video\'
)
);
$list = array();
foreach ($media_query->posts as $post) {
$list[] = array(\'thumbnail\'=>\'\', \'ID\'=>$post->ID,\'title\'=>$post->post_title);
}
//Create an instance of our package class...
$testListTable = new TT_Example_List_Table();
$testListTable->setContent($list);
$testListTable->prepare_items();
$testListTable->display();