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

Inner Join user tables to select users with roles

The Problems You risk SQL injection, with your current setup: $wpdb->users.display_name LIKE ‘$ltr%’ The following could also be a problematic part in your SQL query: AND $wpdb->usermeta.meta_value = %artist% i.e. using = instead of LIKE. You’re also missing the quotes: %\”artist\”%, to exclude e.g. bartist or fartist 😉 But you don’t need to construct this … Read more

Export SQL query based on post type

In your WordPress Dashboard, if you go to Tools > Export, you can select your custom post type and export only posts in that post type. It gives you the option between All Content, Posts, Pages, and your custom post types following those three options. As for SQL, well are you looking to export the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)