How Do I Merge Categories With phpMyAdmin

You can’t simply “merge categories” you have to change the category that each post is associated with. The table WP_TERM_RELATIONSHIPS links posts with categories. You could try something like this: UPDATE wp_term_relationships SET term_taxonomy_id = (SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE term_id = 112748) WHERE term_taxonomy_id = (SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE term_id = 112747) You … Read more

Query to change custom post type with specific category

I would do it in php in two parts rather than one big raw sql statement, for safety reasons, eg in your “functions.php” put: function wpse160706() { $old_post_type=”films”; $new_post_type=”post”; $category_slug = ‘directors’; $taxonomy = ‘category’; global $wpdb; $sql = $wpdb->prepare( ‘SELECT p.ID FROM ‘ . $wpdb->posts . ‘ AS p’ . ‘ JOIN ‘ . … Read more

SQL query to get adjacent posts from search query

Although this is possible, it really is not viable. I’ve done a lot of research on this subject, but could not find a straight forward answer I went and had a look at the WP_Query class for a possible solution, and I came to the conclusion that what I was trying to accomplish would not … Read more

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