From a3d7d6a87ea94fe4ff7e73c96c8240851d3a6931 Mon Sep 17 00:00:00 2001 From: Zach Schnackel Date: Sat, 28 Feb 2015 11:09:04 -0500 Subject: [PATCH] Hopefully resolve search term count issue * Removed transients as this was causing more trouble than it was worth * Make sure SQL query checks for 'publish' status to resolve wrong counts from what was shown vs displayed --- inc/search.php | 23 +++++++++-------------- search.php | 1 - 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/inc/search.php b/inc/search.php index 79d9d22..0d4ef10 100644 --- a/inc/search.php +++ b/inc/search.php @@ -33,20 +33,15 @@ function basey_get_post_type_count($post_type_name) { $search_query = get_search_query(); $search_query_db = preg_replace('/[^a-zA-Z0-9.]/', '', $search_query); - $post_type_count = get_transient('basey_search_' . $post_type_name . '_' . $search_query_db ); - if (false === $post_type_count) { - - // Count number of "total" results returned for each post type - // This is independant of "posts_per_page" - $post_type_count = $wpdb->get_var(" - SELECT COUNT(*) FROM $wpdb->posts - WHERE post_type='$post_type_name' - AND ( post_title LIKE '%$search_query%' - OR post_content LIKE '%$search_query%') - "); - - set_transient( 'basey_search_' . $post_type_name . '_' . $search_query_db, $post_type_count, 60 * 60 ); - } + // Count number of "total" results returned for each post type + // This is independant of "posts_per_page" + $post_type_count = $wpdb->get_var(" + SELECT COUNT(*) FROM $wpdb->posts + WHERE post_type='$post_type_name' + AND post_status='publish' + AND ( post_title LIKE '%$search_query%' + OR post_content LIKE '%$search_query%') + "); return $post_type_count; } diff --git a/search.php b/search.php index 04b7142..63d1ed8 100755 --- a/search.php +++ b/search.php @@ -28,7 +28,6 @@ echo '