Skip to content

Instantly share code, notes, and snippets.

View web-hat's full-sized avatar

WebHat web-hat

View GitHub Profile
@web-hat
web-hat / custom_field_admin_screen.php
Last active September 21, 2019 21:56
Populating custom fields value in product categories admin screen or in categories listing table.
<?php
//Displaying Additional Columns
add_filter( 'manage_edit-product_cat_columns', 'wh_customFieldsListTitle' ); //Register Function
add_action( 'manage_product_cat_custom_column', 'wh_customFieldsListDisplay' , 10, 3); //Populating the Columns
/**
* Meta Title and Description column added to category admin screen.
*
* @param mixed $columns
SELECT p.`ID` AS 'Product ID',
p.`post_title` AS 'Product Name',
t.`term_id` AS 'Attribute Value ID',
REPLACE(REPLACE(tt.`taxonomy`, 'pa_', ''), '-', ' ') AS 'Attribute Name',
t.`name` AS 'Attribute Value'
FROM `wp_posts` AS p
INNER JOIN `wp_term_relationships` AS tr ON p.`ID` = tr.`object_id`
INNER JOIN `wp_term_taxonomy` AS tt ON tr.`term_taxonomy_id` = tt.`term_id`
AND tt.`taxonomy` LIKE 'pa_%'
INNER JOIN `wp_terms` AS t ON tr.`term_taxonomy_id` = t.`term_id`