Created
July 21, 2015 18:10
-
-
Save cdmz/87ba6d7ac0ed9212f422 to your computer and use it in GitHub Desktop.
verify if table exists in database wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include '../../../../wp-load.php'; | |
global $wpdb; | |
$table_name = "wp_posts"; | |
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) { | |
//Your code here | |
} | |
?> |
Better use
$table_name = $wpdb->posts;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will kill your website if you have a significant number of blogs.