add_submenu_page function to show videos table

wondering if its possible to show the attachments admin list for videos by using a custom menu link?

Any pointers welcome! D.

Read More
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><?
}

got this working with class TT_Example_List_Table extends WP_List_Table with help from links below… Looks fine but can’t get edit or delete delete links to work properly.

$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();

Related posts

Leave a Reply

1 comment

  1. I asked a similar question and got this answer, to query the DB for attachments and dump them into a list. This was the code that was provided to me:

    $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[] = wp_get_attachment_url($post->ID);
    }
    // do something with $list here;
    

    Hope this points you in the right direction. My question: Get All Images in Media Gallery?


    EDIT: As far as displaying it in a table, I think you could truly benefit from digging through this code: http://wordpress.org/extend/plugins/custom-list-table-example/

    It has a working example of using WP_List_Table in WordPress. I took one glance and knew it would be a good code to check out. 🙂