Universal problem: first request after ~25 second inactivity always slower (~1 second) than subsequent requests (~1/10sec)

Without looking at your box to see exactly what’s going on, here are some potential avenues of slowness: Potential Causes Apache Apache is usually configured in such a way that a single httpd process is always running in the background. When a request comes in over the wire, it spins up a new httpd process … Read more

How to run this SQL query of wp_terms database

Per comments, you basically have it – just GROUP BY $wpdb->term_relationships.object_id instead; also to be pernickety, you’d use standard (INNER) JOINs rather than LEFT ones: SELECT $wpdb->term_relationships.object_id FROM $wpdb->term_relationships JOIN $wpdb->term_taxonomy ON $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id JOIN $wpdb->terms ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id WHERE name IN (394, 396, 988, 666) GROUP BY $wpdb->term_relationships.object_id ORDER BY $wpdb->term_relationships.term_taxonomy_id DESC

Same option_id=0 for 2 options in wp_options?

If we check how the wp_options table is created (in 4.4) from the schema.php file, we will find the following: CREATE TABLE $wpdb->options ( option_id bigint(20) unsigned NOT NULL auto_increment, option_name varchar(191) NOT NULL default ”, option_value longtext NOT NULL, autoload varchar(20) NOT NULL default ‘yes’, PRIMARY KEY (option_id), UNIQUE KEY option_name (option_name) ) $charset_collate; … Read more

SQL query not working in alphabetical post title/content search

Dude, no need of the SQL mess! WP allows you to search through the post content or titles alphabetically using the search parameter. So, use this solution instead… global $wpdb; $q = $_REQUEST[‘q’]; $posts = get_posts(array(‘s’ => $q, ‘post_type’ => ‘question’, ‘posts_per_page’ => -1)); echo ‘<ul>’; foreach($posts as $post){ echo ‘<li><a href=”‘.get_permalink($post->ID).'”>’.$post->post_title.'</a></li>’; } echo ‘</ul>’; … Read more