diff --git a/assets/script.js b/assets/script.js
index ea6538e..de783cc 100644
--- a/assets/script.js
+++ b/assets/script.js
@@ -18,7 +18,7 @@ jQuery(document).ready(function ($) {
if (selectedTypes.length > 0) appliedFilters.push(`Type: ${selectedTypes.join(', ')}`);
if (selectedSubjects.length > 0) appliedFilters.push(`Subject: ${selectedSubjects.join(', ')}`);
- $('#applied-filters').html(appliedFilters.length ? appliedFilters.join(' | ') : 'None');
+ $('#applied-filters').html(appliedFilters.length ? appliedFilters.join('
') : 'None');
let formData = {
action: 'filter_resources',
@@ -36,7 +36,11 @@ jQuery(document).ready(function ($) {
response = JSON.parse(response);
$('#resource-results').html(response.html);
- $('#result-count').text(response.count);
+ if (response.count !== undefined) {
+ $('#result-count').text(response.count);
+ } else {
+ $('#result-count').text($('#result-count').text()); // Keep initial count
+ }
});
});
});
diff --git a/assets/style.css b/assets/style.css
index cd4b71d..807e5c1 100644
--- a/assets/style.css
+++ b/assets/style.css
@@ -57,9 +57,11 @@
#resource-filter-summary {
display: flex;
gap: .5rem;
+ justify-content: space-between;
margin-bottom: 1.25rem;
+ width: 100%;
- p { margin: 0; }
+ p { margin: 0; padding: 0; }
}
#resource-results {
diff --git a/resource-filter.php b/resource-filter.php
index fa28b54..101f786 100644
--- a/resource-filter.php
+++ b/resource-filter.php
@@ -63,22 +63,29 @@ class ResourceFilterPlugin {
public function renderFilterForm() {
ob_start();
- $template = rfGetTemplate('filter-form.php');
+ $query = new WP_Query([
+ 'post_type' => 'resource',
+ 'posts_per_page' => -1,
+ ]);
- if ($template) {
- include_once $template;
+ $resTotal = $query->found_posts; // Get the count of published resources
+
+ $resForm = rfGetTemplate('filter-form.php');
+ $summary = rfGetTemplate('filter-summary.php');
+
+ if ($resForm) {
+ include_once $resForm;
} else {
- echo '
Error: Template not found.
'; + echo 'Error: Form template not found.
'; } - $total_resources = wp_count_posts('resource')->publish; // Get the count of published resources + if ($summary) { + include_once $summary; + }else { + echo 'Error: Summary template not found.
'; + } ?> -Filters applied: None
-Error: Results template not found.
'; } @@ -166,10 +173,11 @@ class ResourceFilterPlugin { ob_start(); $resources = $query->posts; - $template = rfGetTemplate('resource-results.php'); - if ($template) { - include_once $template; + $resResults = rfGetTemplate('resource-results.php'); + + if ($resResults) { + include_once $resResults; } else { echo 'Error: Results template not found.
'; } diff --git a/templates/filter-summary.php b/templates/filter-summary.php new file mode 100644 index 0000000..b265100 --- /dev/null +++ b/templates/filter-summary.php @@ -0,0 +1,8 @@ + + +Showing resources
+Filters applied:
None