little help with a mySQL query to wp database

Following the recomendations of @toscho i had a look at get_results and the following edits to the function ended up doing the trick. if ( ! function_exists( ‘get_meta_values’ ) ) { function get_meta_values( $key = ”, $type=”post”, $status=”publish” ) { global $wpdb; if( empty( $key ) ) return; $r = $wpdb->get_results($wpdb->prepare( ” SELECT pm.meta_value, pm.post_id … Read more

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