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

Clear Terms from Taxonomy for Specific Post IDs?

So if you’re sure you want to delete the actual term as well as the relationship that assigns the term to the post, this will do it (tested and works for me): delete term from wpterm_taxonomy term, wpterm_relationships rel where term.term_taxonomy_id = rel.term_taxonomy_id and rel.object_id IN (1) ; And obviously replace the ‘1’ there with … Read more

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