I can’t update my data through $wpdb

You’re missing your where statement. You need to tell wpdb which row it should be updating, otherwise you’re looking to insert rather than update. From the $wpdb::update Codex: wpdb->update( string $table, array $data, array $where, array|string $format = null, array|string $where_format = null );

Hide posts if user is added to it WP_query

Hopefully i understood correctly what you want to achieve here. If you want to exclude all posts that contain get_current_user_id() in the project_users ACF repeater, but at the same time contains has get_current_user_id() in favourite_users, the correct meta query looks like this: ‘meta_query’ => array( ‘relation’ => ‘AND’, array( array( ‘key’ => ‘project_users’, ‘value’ => … Read more

Update Custom Post Type Taxonomies with SQL

Why am I getting this error? Because the table wp_term_taxonomy does not have the column object_id. And the correct table that you should update is the wp_term_relationships table which does have the column object_id. See the WordPress database diagram and also the WordPress database description for more details. So your SQL query should be: UPDATE … Read more

Replace a character in all post titles and slugs

Slugs are saved in the very same table but in the post_name column. So your query would look like this: UPDATE wp_posts SET post_name = REPLACE(post_name, ‘m’ , ‘p’) WHERE post_type=”post” AND post_status=”publish”; By the way, I’d suggest you to use $wpdb->posts instead of just wp_posts ( then it would be compatible with different prefixes, … Read more

Basic wpdb update question

I think the line should be: $selected_candidate = $_POST[‘candidat’]; => $selected_candidate = $_POST[‘selectCandidate’] Btw. You are using “prepare” in the wrong way. You are not protecting yourself from sql injections, use it like this: $wpdb->query( $wpdb->prepare(“UPDATE pp_candidates SET candidate_approved = 1 WHERE candidate_ID = %d”, $selected_candidate));