Set Display Name to first and last name (phpmyadmin SQL Query)

I know this is an old question, but for anyone still looking how to achieve this, the following query should do the job: UPDATE wp_users INNER JOIN wp_usermeta AS fn_meta ON wp_users.ID = fn_meta.user_id AND fn_meta.meta_key = ‘first_name’ INNER JOIN wp_usermeta AS ln_meta ON wp_users.ID = ln_meta.user_id AND ln_meta.meta_key = ‘last_name’ SET wp_users.display_name = CONCAT(fn_meta.meta_value, … Read more

Can I run multiple queries with $wpdb->prepare?

Outside of subqueries, MySQL will only process 1 query at a time. When running sql statements through phpmyadmin, it just executes 1 query after the other. To do the same thing in WordPress, it appears you just use 1 query per $wpdb object (those can have subqueries if desired, but not what’s needed here).

Can’t publish new posts

There are, still, references to old domain in your database, which have to be fixed. Step 1: go to Settings -> Permalinks and click on Save Changes button. This will fix your permalinks. Step 2: install and activate Better Search Replace plugin. Go to Tools -> Better Search Replace. Replace the old domain ( example.com … Read more

Slow Mysql Queries

WP options (which is one of the most basic and used storage APIs) can be stored with or without “autoload” setting. Usually this is reasonable, since many options will be checked on each and every page load, so loading them in bulk during core load is much more efficient than individually. Problems usually start when … Read more

How to add and SQL query of posts only published

You should be able to get away with just adding AND $wpdb->posts.post_status=”publish” at the end. $prepare_string = ” SELECT DISTINCT ID FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id ) LEFT JOIN $wpdb->postmeta AS mt1 ON ( $wpdb->posts.ID = mt1.post_id ) WHERE ( ( $wpdb->postmeta.meta_key = ‘event_date’ AND $wpdb->postmeta.meta_value >= %d ) OR … Read more