refactor: Update resource filter to use global posts total and set query count

This commit is contained in:
Keith Solomon
2025-03-27 15:58:31 -05:00
parent 733d5c3fec
commit 71b8d4261f

View File

@@ -184,7 +184,8 @@ class ContentFilterPlugin {
$query = $this->getQuery();
define('RF_TOTAL_RESOURCES', $query->found_posts);
global $postsTotal;
$postsTotal = $query->found_posts;
ob_start();
@@ -309,15 +310,22 @@ class ContentFilterPlugin {
// Sorting logic
$query_args = $this->applySorting($query_args, $sort_order);
return new WP_Query($query_args);
$query = new WP_Query($query_args);
$query->set('count', $query->found_posts);
return $query;
} else {
return new WP_Query([
$query = new WP_Query([
'post_type' => $postTypes,
'posts_per_page' => $postCount,
'paged' => max(1, get_query_var('paged', 1)), // Get current page number
'tax_query' => $this->buildDynamicTaxQuery(),
's' => $strSearch,
]);
$query->set('count', $query->found_posts);
return $query;
}
}