Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cdmz/87ba6d7ac0ed9212f422 to your computer and use it in GitHub Desktop.
Save cdmz/87ba6d7ac0ed9212f422 to your computer and use it in GitHub Desktop.
verify if table exists in database wordpress
<?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
}
?>
@ravloony
Copy link

This will kill your website if you have a significant number of blogs.

@ramonfincken
Copy link

Better use
$table_name = $wpdb->posts;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment