SHARE
TWEET

Untitled

a guest Jul 17th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. if( ! function_exists( 'prefix_get_all_post_meta_keys' ) ) :
  3.     /**
  4.      * Get all meta keys.
  5.      *
  6.      * @return mixed Array of the meta keys.
  7.      */
  8.     function prefix_get_all_post_meta_keys() {
  9.         global $wpdb;
  10.  
  11.         $sql = "SELECT DISTINCT meta_key
  12.             FROM $wpdb->postmeta
  13.             WHERE meta_key NOT BETWEEN '_' AND '_z'
  14.             HAVING meta_key NOT LIKE %s
  15.             ORDER BY meta_key";
  16.  
  17.         $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%' ) );
  18.  
  19.         return $keys;
  20.     }
  21. endif;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top