Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the easy-digital-downloads domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/danigirol0/www/wp-includes/functions.php on line 6121

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/danigirol0/www/wp-includes/functions.php on line 6121

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the metform domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/danigirol0/www/wp-includes/functions.php on line 6121
Mostrar valores de un atributo en una columna personalizada del listado de productos - Dani Girol

Mostrar valores de un atributo en una columna personalizada del listado de productos

add_filter( 'manage_edit-product_columns', 'dpw_change_product_columns',10, 1 );


function dpw_change_product_columns( $columns ) {

	unset($columns['product_tag']);
unset($columns['sku']);
	unset($columns['product_type']);
	$columns['proveedor'] = 'Dolibar'; 

	return $columns;

}


// Mostrar valores de un atributo en una columna personalizada del listado de productos

add_action('manage_product_posts_custom_column', 'dpw_product_columns_content', 5, 2);


function dpw_product_columns_content($column_name, $post_ID) {

	if ($column_name == 'proveedor') {

		//Buscamos los valores del atributo 'proveedor' y los mostramos.
		if($proveedores = get_the_terms( $post_ID, 'pa_proveedor')){
				foreach ( $proveedores as $proveedor ) {
					echo 'DANI'.$proveedor->name;
				}
		}
	}
	
}