Delete all drafts?

draft is not a post_type, it’s a post_status. So you should use your second block of code with that substitution: DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_status=”draft”

Is it possible to query from external database? [duplicate]

You can use wpdb to setup a new connection. Add something similar to this below in your functions.php and you can then query just like you would normally but using the new connection. $second_db = new wpdb(DB_USER, DB_PASSWORD, $database_name, DB_HOST); $results = $second_db->get_results($your_query); references: https://wordpress.stackexchange.com/a/1673/86845 https://stackoverflow.com/a/36759606/3204142

Display Data in Table from External Database in WP using Shortcodes

While it is VERY bad practice to have spaces in the object names, there are times where it may be out of your control. You can use the syntax of $object->{‘Property Name’}, like this: // add the shortcode [pontoon-table], tell WP which function to call add_shortcode( ‘pontoon-table’, ‘pontoon_table_shortcode’ ); // this function generates the shortcode … Read more

Specifying meta field’s column type in Database using add_post_meta

When you use add_post_meta, no column in database is created. All post meta data is stored in wp_postmeta table (https://codex.wordpress.org/Database_Description#Table:_wp_postmeta). Here’s the structure of that table: post_id is the ID of post that this meta data is assigned to meta_key is the key of meta (in your case favourite_fruit_code) meta_value is the value of that … Read more

Issue running db create table query from static method

plugin_dir_url() returns the URL directory path for your plugin, so this won’t work as expected (the function won’t be called): register_activation_hook(plugin_dir_url(__FILE__) . ‘frequentVisitorCoupons.php’, ‘Utilities::createTablesIfNotExists’); You should have used plugin_dir_path() which returns the file-system directory path for your plugin (e.g. /var/www/public/<user>/wp-content/plugins/your-plugin/). But if the code is in the main plugin file, then you could simply use … Read more

How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?

Yes, WordPress checks for duplicate emails internally, but not duplicate usernames To test this I ran this several times via wp shell: wp_create_user( ‘test’, ‘password’, ‘[email protected]’ ); The result on the second attempt was: => class WP_Error#1962 (2) { public $errors => array(1) { ‘existing_user_email’ => array(1) { [0] => string(42) “Sorry, that email address … Read more