Created
March 15, 2017 14:08
-
-
Save tommcfarlin/206b5b224488db5ba5e28ee106286695 to your computer and use it in GitHub Desktop.
[WordPress] Load All WordPress Custom Fields via Database Query
This file contains 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 | |
function get_the_custom_fields() { | |
global $wpdb; | |
$results = $wpdb->get_results( | |
$wpdb->prepare( | |
" | |
SELECT meta_key, meta_value | |
FROM $wpdb->postmeta | |
WHERE meta_key REGEXP '%s' | |
", '^[_]' | |
) | |
); | |
return $results; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment