add_action ‘manage_posts_custom_column’ in a class [closed]
Your problem is a simple typo: array($this, ‘manage_post_columns’, 10, 2) VS. array($this, ‘manage_post_columns’), 10, 2 I guess you see the difference
Your problem is a simple typo: array($this, ‘manage_post_columns’, 10, 2) VS. array($this, ‘manage_post_columns’), 10, 2 I guess you see the difference
If you add a bulk-action, then you have to react on this action. Simply adding a function doesn’t do anything, you have to call it: class WPSE_List_Table extends WP_List_Table { public function __construct() { parent::__construct( array( ‘singular’ => ‘singular_form’, ‘plural’ => ‘plural_form’, ‘ajax’ => false ) ); } public function prepare_items() { $columns = $this->get_columns(); … Read more
To achieve adding a custom sortable column to the WP_List_Table of your post type within the WordPress administration back-end dashboard, you will need to do the following: Replace all occurrences of YOUR-POST-TYPE-NAME with your actual post type name. Replace all occurrences of YOUR-TAXONOMY-NAME with your actual taxonomy name. Replace all occurrences of YOUR COLUMN NAME … Read more
I don’t know what you mean by dirty way, hopefully not core editing! You can hide it with CSS. Or you can do it with PHP – see below: Hide the views part You can remove the views part with add_filter( ‘views_edit-post’, ‘__return_null’ ); for the post post type on the edit.php screen. The post … Read more
Your WP_List_Table will be different — this was adapted from WP_List_Table – a step by step guide and using the GIST: Sample plugin for usage of WP_List_Table class (complete version). You’ll want to adjust your methods to include CSS on the front-end as well (not included in this answer). WARNING : Since this class is … Read more
As mentioned in the comments, if this is an existing table you wish to add/remove links from, see this answer. If this a custom subclass of WP_List_Table, e.g.: class Wpse56883_WP_List_Table extends WP_List_Table{ //Class methods here } Then you add these links by overriding the get_views() method. This should return an array: array ( id => … Read more
Code class Kv_subscribers_list extends WP_List_Table { function __construct(){ global $status, $page; parent::__construct( array( ‘singular’ => ‘notification’, ‘plural’ => ‘notifications’, ‘ajax’ => false ) ); } protected function get_views() { $status_links = array( “all” => __(“<a href=”#”>All</a>”,’my-plugin-slug’), “published” => __(“<a href=”#”>Published</a>”,’my-plugin-slug’), “trashed” => __(“<a href=”#”>Trashed</a>”,’my-plugin-slug’) ); return $status_links; } function column_default($item, $column_name){ switch($column_name){ case ’email’: case … Read more
Assuming you’re using the standard column_cb() function, the list table will pass the IDs of the selected rows in an array in $_GET, labeled as whatever you assigned to ‘singular’ in the list table’s constructor. Here’s a typical column_cb(): function column_cb($item){ return sprintf( ‘<input type=”checkbox” name=”%1$s[]” value=”%2$s” />’, /*$1%s*/ $this->_args[‘singular’], //Let’s simply repurpose the table’s … Read more
Since 3.1 there’s a class WP_List_Table which makes it a hella lot easier to render tables for an array of data objects. There’s very little documentation (read: none) on it yet, but you can check out the source if you’re familiar with PHP.
If you don’t wish to always click the “Title” column to sort your posts by title, you can place this code in either your currently active WordPress theme’s functions.php file, or within a plugin. This will automatically always sort your posts for you, so you don’t have to click the title column every time. You … Read more