How to create a column

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;
}
Close Menu