Created
January 17, 2021 03:55
-
-
Save gvgvgvijayan/be44c43a1f59db909ab7afc9c0de8086 to your computer and use it in GitHub Desktop.
Revisions
-
gvgvgvijayan created this gist
Jan 17, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ <?php ... /** * Prepare the data for the WP List Table * * @return void */ public function prepare_items() { $columns = $this->get_columns(); $sortable = $this->get_sortable_columns(); $hidden = array(); $primary = 'title'; $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); $data = array(); $this->process_bulk_action(); $get_posts_obj = $this->get_posts_object(); if ( $get_posts_obj->have_posts() ) { while ( $get_posts_obj->have_posts() ) { $get_posts_obj->the_post(); $data[ get_the_ID() ] = array( 'id' => get_the_ID(), 'title' => get_the_title(), 'type' => ucwords( get_post_type_object( get_post_type() )->labels->singular_name ), 'date' => get_post_datetime(), 'author' => get_the_author(), ); } wp_reset_postdata(); } $this->items = $data; $this->set_pagination_args( array( 'total_items' => $get_posts_obj->found_posts, 'per_page' => $get_posts_obj->post_count, 'total_pages' => $get_posts_obj->max_num_pages, ) ); } ...