Created
October 3, 2016 20:15
-
-
Save adamplabarge/11da680d43b3ab53fe0146a8084ac156 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('genesis_before', function() { | |
global $wpdb; | |
$post_type = 'product'; | |
$query = " | |
SELECT DISTINCT($wpdb->postmeta.meta_key) | |
FROM $wpdb->posts | |
LEFT JOIN $wpdb->postmeta | |
ON $wpdb->posts.ID = $wpdb->postmeta.post_id | |
WHERE $wpdb->posts.post_type = '%s' | |
AND $wpdb->postmeta.meta_key != '' | |
AND $wpdb->postmeta.meta_key NOT RegExp '(^[_0-9].+$)' | |
AND $wpdb->postmeta.meta_key NOT RegExp '(^[0-9]+$)' | |
"; | |
$meta_keys = $wpdb->get_col($wpdb->prepare($query, $post_type)); | |
dump($meta_keys); | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment