InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Wordpress How-Tos

  • angularjs in wordpress
  • Convert wordpress page to posts and vice versa
  • Find all user created wordpress custom field keys
  • How to automate wordpress sandbox setup on Linux
  • How to capture php code or included file output in a variable
  • How to check the performance of a plugin using mysql query log
  • How to migrate wordpress from root to sub directory
  • How to upgrade wordpress manually
  • How to view wordpress current version
  • Setup xdebug for remote wordpress debugging
  • Wordpress - disable theme and plugin editing
  • Wordpress - get wpdb class method names
  • Wordpress multisite network vs normal installation
  • display method names from php WP_Query object
  • find if a wordpress page is leaf page
 
  • Home
  • > Tutorials
  • > Wordpress
  • > Wordpress How To

Find all user created wordpress custom field keys

By admin on Nov 17, 2015

Sometime we need to find all user created custom field key names (or meta key) in wordpress. This may be needed to find all posts and pages having a certain custom field key and value for audit/review purpose. Here is code which can be used for this:

  global $wpdb;
  $querystr = "
    SELECT distinct $wpdb->postmeta.meta_key 
    FROM $wpdb->postmeta
    WHERE $wpdb->postmeta.meta_key NOT BETWEEN '_' AND '_z'
    ORDER BY $wpdb->postmeta.meta_key
  ";
  $res_list = $wpdb->get_results($querystr);
  if ($res_list) {
    echo "custom keys:\n";
    foreach ($res_list as $obj) {
      $key = $obj->meta_key;
      echo "$key\n";
    }
  }

Suggested posts:

  1. PHP check if key exists in array
  2. HTML li tag
  3. Vim – how to go back to last edited line/context
  4. Fetch wordpress rss feed as FeedBurner user agent on command line
  5. How to setup MailChimp Rss email campaign
  6. Curl – follow redirects
  7. How to create ssh public/private keys on command line
  8. Using ssh sftp updater support for updating wordpress plugins and themes
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Linux, Tutorials, Web Development, Wordpress, Wordpress How To
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress