2 $wpdb queries causing error Table ‘wp_postmeta’ is specified twice, both as a target for ‘UPDATE’
2 $wpdb queries causing error Table ‘wp_postmeta’ is specified twice, both as a target for ‘UPDATE’
2 $wpdb queries causing error Table ‘wp_postmeta’ is specified twice, both as a target for ‘UPDATE’
You should gotten return from SQL first. And then print results. Use $wpdb class for SQL queries. If you wanna use native SQL queries something like this might helps you $result = mysql_query(“SELECT * FROM table”); $result_array = mysql_fetch_array($result, MYSQL_ASSOC); But it`s very bad idea. Use $wpdb with preparing.
$category_slug_array = array(‘slug_1’, ‘slug_2’, ‘slug_2’); //array of category slugs foreach($category_slug_array as $category_slug){ $my_categories[] = get_term_by( ‘slug’, $category_slug, ‘category’); //getting category object by slug } print_r($my_categories); //printing array of categories
WordPress 4.8.2 specifically restricts the convenient usage of numbered placeholders like %1$s, %1$d, %1%f in WPDB::prepare. (core.trac.wordpress.org/ticket/41925). To avoid usage of numbered placeholders, SQL query has to be rearranged to just use only one %s. SELECT DISTINCT t.`Date`, y.* FROM `table` t LEFT JOIN `table` y ON (t.`Date` = y.`Date`) WHERE t.`country` = %s ORDER … Read more
How to refactor DB queries for better TTFB in WordPress?
You could try this: $args = array(“post_type” => “mytype”, “s” => $title, ‘post_status => array(‘draft’)); $posts = get_posts( $args );
Slow wp_posts and wp_postmeta query using Advance Custom Fields
To do this reliably, you’re going to have to fetch each user and pull in the meta then write it out again 1 by 1. Use a custom WP CLI command to do this. If you don’t have SSH access you can pull down a copy of the site and run it on your machine … Read more
Okay. I solved it by myself. i dunno what’s wrong, but it looks like using first case – just doesn’t work. using second case – is a bad idea. so i began to work with sql and posts_where commands. first: instead of $wp_query->query_vars[‘s’] i started to use get_search_query() second: looks like when sql tries to … Read more
WordPress database issues – menu not saving correctly, media thumbnails not showing