Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created March 15, 2017 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/206b5b224488db5ba5e28ee106286695 to your computer and use it in GitHub Desktop.
Save tommcfarlin/206b5b224488db5ba5e28ee106286695 to your computer and use it in GitHub Desktop.
[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