Skip to content

Instantly share code, notes, and snippets.

@filipecsweb
Last active April 10, 2019 01:49
Show Gist options
  • Save filipecsweb/0669ae7afe20abffab0c to your computer and use it in GitHub Desktop.
Save filipecsweb/0669ae7afe20abffab0c to your computer and use it in GitHub Desktop.
Add custom value to custom column in shop_order post type
<?php
/**
* Add custom value to custom column in admin on page that lists the shop_order post type.
*
* @param string $column This is the column id/key.
*/
function add_custom_column_value_to_shop_order( $column ) {
global $post;
if ( $column == 'software_key' ) {
echo null !== get_post_meta( $post->ID, 'software_key' ) ? get_post_meta( $post->ID, 'software_key', true ) : '-';
}
}
add_action( 'manage_shop_order_posts_custom_column', 'add_custom_column_value_to_shop_order' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment