SQL DELETE multiple post_meta on single and multi-sites
SQL DELETE multiple post_meta on single and multi-sites
SQL DELETE multiple post_meta on single and multi-sites
Tom’s comment on the question makes a very important point: unless you are just using this SQL for diagnostic or exploratory purposes, there is almost definitively an easier and more efficient means to access this data, either through the WordPress APIs or via tools like WP CLI. There is virtually no reason to use this … Read more
You need to pass your attributes in the shortcode as key-value pairs, and use them in php as an array as follows: [tagtagtag tag_id=246] function get_categories_with_product_in_tag( $atts ) { global $wpdb; return $wpdb->get_results( $wpdb->prepare( “SELECT categories.* FROM “. “{$wpdb->prefix}terms categories “. “INNER JOIN {$wpdb->prefix}term_taxonomy ctax ON (categories.term_id = ctax.term_id) “. “INNER JOIN {$wpdb->prefix}term_relationships crel ON … Read more
DB prefix not updating
I managed to solve after several attempts using the following code: // Insert the role $role = array(‘gold_role’ => 1); $serialized_role = serialize($role); $DB_MEMBERSHIP->insert(‘wpvm_usermeta’, array(‘user_id’ => $user_id, ‘meta_key’ => ‘wpvm_capabilities’, ‘meta_value’ => $serialized_role)); It works very well and doesn’t slow down the shopping experience.
Custom SQL query slows down when using multiple OR … LIKE … in posts_where filter
In this pursuit, since the students could be thousands in a school, would it be a good practice to have so many entries in the wp_users table by creating a separate user_role : students’? A separate user role will make no difference to site performance or scalability. Or should I create a separate table to … Read more
Menu Order updating automatically
How to run complex query using PHP
A possible solution is to use the pre_get_posts action: add_action(‘pre_get_posts’, ‘custom_search_query’); function custom_search_query($query) { // run only if is a search query and if the search string is not empty if($query->is_search() && $query->is_main_query() && get_query_var(‘s’, false)) { // here you can use your custom query having ‘get_query_var(‘s’, false)’ as $Search string //”SELECT SQL_CALC_FOUND_ROWS *………. // … Read more