How to create a column

This tutorial is for developers.

You can use this snippet to add a custom columns to the “posts” spreadsheet (change ‘post’ with the other post type key if you want).

add_action('vg_sheet_editor/editor/before_init', 'wpse_register_columns');
function wpse_register_columns($editor) {
if ($editor->args['provider'] === 'post') {
$editor->args['columns']->register_item('wpse_multiple_roles', 'post', array(
'data_type' => 'meta_data',
'supports_formulas' => false,
'allow_to_save' => false,
'get_value_callback' => 'wpse_get_stats_value_for_post',
));
}
}
function wpse_get_stats_value_for_post($post, $cell_key, $cell_args) {
// Get stats number from the database
$value = '';
return $value;
}

Do you need help?

You can receive instant help in the live chat during business hours, or you can contact us and we will help you via email.