How to get a list of all table prefixes within the same database? Home › Forums › WordPress Development › How to get a list of all table prefixes within the same database? Tagged: prefix, wpdb This topic has 0 replies, 1 voice, and was last updated 3 weeks, 5 days ago by Rafasashi. Viewing 0 reply threads Author Posts August 29, 2024 at 1:01 pm #8945 RafasashiKeymaster This snippet lists all table prefixes from other WordPress installations within the same database: function get_prefix_options(){ global $wpdb; $table_names = $wpdb->get_results("SHOW TABLES LIKE '%_postmeta'", ARRAY_N); $prefixes = array(); foreach ($table_names as $table) { $prefix = str_replace('_postmeta', '', $table[0]); if ( !in_array($prefix,$prefixes) ) { $prefixes[] = '_' . $prefix; } } return $prefixes; } Author Posts Viewing 0 reply threads You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Website Captcha SVGCaptcha Log In