Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[WordPress] Load All WordPress Custom Fields via Database Query
<?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
You can’t perform that action at this time.