DB_HOST – is LOCALHOST speedy than domain name? [closed]

Usually you only have to use mysql.domain.com if connecting to a remote database. If that is what you are doing, then yes. It will be slower than a locally hosted database. Even if the domain resolves to the local server localhost should resolve quicker as it uses the loopback interface which bypasses network hardware.

What does the $posts_join filter join to?

posts_join is only a part of the full SQL query, the table you’re joining to is referenced earlier in the query. You can see the full query with the posts_request filter. See the documentation for the rest of the query filters.

How can i restore only Blogs from a SQL backup file?

“Blogs” or posts as they are called in WordPress are stored in the wp_posts table of your database. And custom fields related to your posts are stored in wp_postmeta table. So you should just be able to restore those two tables to get all your “Blogs”. This assumes your database is prefixed with wp_ of …

Read more

Connect to Ms SQL Server

You have probably figured it out by now, but just in case. I was also asked to pull data from an MS SQL server and present the data on a WordPress site. In my plugin, I stored the connection values (encrypted) as options. Here are the basics. Connection Function: public function rimsdb() { global $rimsdb; …

Read more

Why line returns are not reapply after doing esc_sql?

That’s not what esc_sql is for, or what it should be used for. Safely Escaping Variables In SQL Queries To make variables safe for an SQL query, use $wpdb->prepare, e.g. $table_name = “{$wpdb->prefix}myTable”; $myID = 12; $wpdb->query( $wpdb->prepare( “UPDATE `$table_name` SET `your_column_1` = 1 WHERE `$table_name`.`your_column_id` = %d”, $myID ) ); Notice that $myID is …

Read more

Removing posts by sql

You’re probably better off doing this with wordpress functions and adding a button which would delete all posts (or even having a shortcode that, when loaded, would do it). The reason I recommend doing this instead of SQL directly is that wp_delete_post() will take all the associated meta with it, which saves you having to …

Read more

Posts modified in the last 48 hours

You can do it easily with WP_Query: $args = array( ‘date_query’ => array( ‘relation’ => ‘OR’, array( ‘column’ => ‘post_date’, ‘after’ => ‘-2 days’ ), array( ‘column’ => ‘post_modified’, ‘after’ => ‘-2 days’ ) ) ); $query = new WP_Query( $args ); More information about date_query parameter of WP_Query. If, for some reason, you still …

Read more