InfoHeap
Tech tutorials, tips, tools and more
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. Mysql query to find all yoast meta description
  2. Handle pagination in wordpress custom php code
  3. Using WordPress custom field for displaying code
  4. WordPress mysql query to get all custom keys and values for a post
  5. How to display wordpress page list with specific custom field value
  6. WordPress mysql query to get all posts with a missing custom field
  7. WordPress mysql query to get all posts with a specific custom field
  8. How to show wordpress pages on front page with skip_home custom field
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

Follow InfoHeap

facebook
twitter
googleplus
  • Browse site
  • Article Topics
  • Article archives
  • Recent Articles
  • Contact Us
  • Omoney
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | 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

Copyright © 2023 InfoHeap.

Powered by WordPress