I would like to add a new column in the back-end table for Product Categories. This column will contain a link "view category" and will link all to the www.domain.com/category/category-name page.
I looked into the Wordpress docs and this is the code I came up with... but it doesn't work!
function product_cat_cpt_columns($columns) {
$new_columns = array(
'Link' => "Link to page"
);
return array_merge($columns, $new_columns);
}
add_filter('manage_product_cat_posts_custom_columns' , 'product_cat_cpt_columns');
Any idea how I would do this? I really appreciate your help!
Pulling from this answer you can add columns to the Edit Tags screen with the following code:
I found it suprisingly hard to find a solution for such a trivial task and I'm very thankful to Helgatheviking for her answer that pointed me to the right direction. Her answer didn't quite work for me, because it would allow only the same value for all the column values, so I decided to post an improved version here.
The problem was with the second function, because it didn't provide a way to add field's value that is corresponding to the current category. I've dug through Woocommerce's source (there you could search for "product_cat_column" to go through relevant parts and see how it's made) and found out that this filter accepts 3 paramaters, not 1. That allows for a specific value per row, not the same value for all rows, as it is in Helgatheviking's answer.
Another drawback was that it would put the value to the thumbnail's column, because that is what Woocommerce use this filter for, actually.
So here's my code:
As you can see, the first function stays the same, but the second now checks for the column name and returns the content depending on this name. You can get any category meta this way and do it for as many columns as you'd like.