How to add and SQL query of posts only published

You should be able to get away with just adding AND $wpdb->posts.post_status=”publish” at the end. $prepare_string = ” SELECT DISTINCT ID FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id ) LEFT JOIN $wpdb->postmeta AS mt1 ON ( $wpdb->posts.ID = mt1.post_id ) WHERE ( ( $wpdb->postmeta.meta_key = ‘event_date’ AND $wpdb->postmeta.meta_value >= %d ) OR … Read more

wp_admin edit.php slow with lots of queries

One way to do this (and yes, it is ugly and hackish) is to create a custom page having a custom page template that draws out all of your posts and creates the proper admin url links for each one. For example: <?php /* Template Name: View Posts Quickly */ if ( !is_user_logged_in() ) { … Read more

How to check for empty and not a failure

You test for a fail by explicitly testing for false: if (null === $mypostids) { /* it failed */ } NB: three equals signs! you want to check for identical, not just equivalent edit: originally said false, changed to null after looking at get_result() function in source.

Concurrent / simultaneous MySQL connections

IMHO that would depend on the hosting company and what resources you are limited to. Let’s say you pick Amazon’s MySQL RDS. There are seven server models permitted. Each model allows a maximum value for the number of connections. I wrote a post about this last month in the DBA StackExchanage : Should I increase … Read more

How to bulk edit canonical url’s in SQL?

Down- and uploading CSVs is a tough one that forces you to make a bunch of steps manually which is prone to human error (and typos). My suggestion would be to do something that you can battletest locally in a local copy of your DB. Steps to follow: Make a database dump using the mysqldump … Read more

Importing MariaDB into Mysql in WordPress

While at the current point in time there is very little difference, and maybe no difference at all, this is a bad practice if your development environment supposed to replicate the server your code will run on. There is just no point in forking a product without having the intention to change it, and the … Read more