The paging is very slow under a large number of articles

The two most obvious things you can do to reduce the load time of this query are the IN statement and the offset in your LIMIT statement. The larger the number of items you’re checking for in the IN statement, the less efficient the query. See: https://stackoverflow.com/questions/4514697/mysql-in-operator-performance-on-large-number-of-values The reason the offset is causing performance issues … Read more

How to get INSERT errors from $wpdb?

To insert data you should use query() (documentation), get_var() method is for selecting data. If error is encountered, query() returns FALSE. query() This function returns an integer value indicating the number of rows affected/selected for SELECT, INSERT, DELETE, UPDATE, etc. For CREATE, ALTER, TRUNCATE and DROP SQL statements, (which affect whole tables instead of specific … Read more

problem with sql query

Your code should look something like this: $this->table_name=”table_name”; $how_much = $this->wpdb->get_var(“SELECT COUNT(*) FROM $this->table_name”); We don’t need to use the prepare method, since this is not meant for table names, more here And also… as you what are trying to do is going not in a good direction… I don’t what to criticize you or … Read more

Query where ANDing slug values not working

You can do this using the WP APIs like this: $args = [ ‘post_type’ => ‘post’, ‘tax_query’ => [ ‘relation’ => ‘AND’, [ ‘taxonomy’ => ‘your_taxonomy_name’, ‘field’ => ‘slug’, ‘terms’ => array( ‘arizona’, ‘speech-language-pathology’ ), ] ], ]; $query = new WP_Query( $args ); Then you can use $query as you would any standard post … Read more

How to Assign / Move all Deleted post to a category

Option 1: backup – Many hosts offer backups. Sometimes you have to pay for them, but often even when you do, they’ve actually been backing everything up and paying just allows you to access them. Worth checking as this will be fastest. Option 2: post listing screen – If these posts all had only 1 … Read more

Woocommerce Backend Search by Title and SKU

Please try this code function search_by_sku( $search, &$query_vars ) { global $wpdb, $pagenow; if ( ‘edit.php’ != $pagenow || ! is_search() || ! isset( $query_vars ->query_vars[‘s’] ) || ‘product’ != $query_vars ->query_vars[‘post_type’] ) { return $search; } if(isset($query_vars->query[‘s’]) && !empty($query_vars->query[‘s’])){ $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘product’, ‘meta_query’ => array( array( ‘key’ => … Read more