Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Add custom values to wp-list-table WordPress

  • SOLVED

How i can add a shortcode from my plugin to the plugin wp-list-table?

Answers (2)

2019-09-29

timDesain Nanang answers:


add_filter('manage_arti_carousel_posts_columns', 'timd_arti_carousel_columns');
function timd_arti_carousel_columns($cols) {

$cols['anti_carousel'] = 'Carousel';

return $cols;
}

add_action('manage_arti_carousel_posts_custom_column', 'timd_arti_carousel_value', 10, 3);
function timd_arti_carousel_value($column) {
global $wpdb, $post;

$post_id = $post->ID;

switch($column) :
case 'anti_carousel' :
echo '[arti_carousel id="'.$post_id.'"]';
break;
endswitch;
}


timDesain Nanang comments:

read more: https://codex.wordpress.org/Plugin_API/Action_Reference/manage_$post_type_posts_custom_column


User183722 comments:

Nice, thanks for your fast answer. Is it possible to shift the order? I prefer to have the Date after the Shortcode...


timDesain Nanang comments:


add_filter('manage_arti_carousel_posts_columns', 'timd_arti_carousel_columns');
function timd_arti_carousel_columns($cols) {

$temp = $cols;
unset($cols);

$cols['cb'] = 'cb';
$cols['title'] = __('Title');
$cols['anti_carousel'] = 'Carousel';

$cols = array_merge($cols, $temp);

return $cols;
}

2019-09-29

Hugo Gonçalves answers:

Hi there!

I think it's not intended to be used like that:
https://codex.wordpress.org/Class_Reference/WP_List_Table

"This class's access is marked as private. That means it is not intended for use by plugin and theme developers as it is subject to change without warning in any future WordPress release."