• Resolved Richard Foley

    (@richardfoley)


    hi, I’m trying to include the SKU field, (it’s about 10 chars), on the downloads listing under the WP admin dashboard.

    /wp-admin/edit.php?post_type=download

    This should be so simple, I was expecting a config entry which says “display SKU” -> yes|no. Not found this yet, is there another, easy, way to do this?

    Thanks in advance for any helpful suggestions.

    Cheers.

    R.

    https://wordpress.org/plugins/easy-digital-downloads/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Pippin Williamson

    (@mordauk)

    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?

    Thread Starter Richard Foley

    (@richardfoley)

    Not yet, but I’m all ears…

    Plugin Contributor Pippin Williamson

    (@mordauk)

    Take a look at this codex page. It shows how to do it: https://codex.wordpress.org/Plugin_API/Filter_Reference/manage_edit-post_type_columns

    Thread Starter Richard Foley

    (@richardfoley)

    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.

    Thread Starter Richard Foley

    (@richardfoley)

    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…?

    Thread Starter Richard Foley

    (@richardfoley)

    ps. thanks for your patience… :\

    Thread Starter Richard Foley

    (@richardfoley)

    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…

    Plugin Contributor Pippin Williamson

    (@mordauk)

    Could you show me your complete code?

    Thread Starter Richard Foley

    (@richardfoley)

    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.

    Plugin Contributor Pippin Williamson

    (@mordauk)

    Glad to hear it!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Include SKU in /wp-admin/edit.php?post_type=download listing’ is closed to new replies.