Hi Richard,
At the moment we don’t include a way to display SKU field in the list table, but it could be added with some simple PHP.
Are you familiar with the add_filter() function in WordPress?
Not yet, but I’m all ears…
hi Pippin, that looks very useful. Clearly I’m going to have to WP RTFM some more in future.
Many thanks for the both prompt and helpful response.
:thumbs-up
R.
Correction, nearly thumbs-up. I have the column with the correct “SKU” title, and the field is accessed from within the filter like so:
$new_columns = array(
‘edd_sku’ => __(‘SKU’),
);
However, the contents of the field are empty. Looking at your code, it seems one of these keys should fetch the field, but it doesn’t seem to make any difference whether I use “sku”, “edd_sku”, or “id” as the key, nothing (no data) appears. Which is a little odd.
I presume I’m doing something (simple) wrong…?
ps. thanks for your patience… :\
pps. yes, the field has data.
I can see “edd_sku” => “the_correct_sku_value” in the postmeta table, and I can see the data when I open the download/post directly.
It’s only in the “/wp-admin/edit.php?post_type=download” listing where there is a title, but no value…
Could you show me your complete code?
hi Pippin,
I’ve used a plugin to do this in the meantime, and it’s fine. All the same, the code I was using was:
function download_cpt_columns($columns) {
$new_columns = array(
'edd_sku' => __('SKU', 'Beluga-child'),
);
return array_merge($columns, $new_columns);
}
add_filter('manage_edit-download_columns' , 'download_cpt_columns');
Cheers.