diff --git a/assets/script.js b/assets/script.js index 112392b..cfb4f0f 100644 --- a/assets/script.js +++ b/assets/script.js @@ -75,8 +75,14 @@ jQuery(document).ready(function ($) { $('#result-count').text(response.count); // Update pagination - if (response.pagination) { + if (response.pagination && response.pagination.length > 0) { + // Clear and update pagination container + if (!$('.pagination').length) { + $('#resource-results').after('
'); + } $('.pagination').html(response.pagination.join('')); + } else { + $('.pagination').html(''); // Clear pagination if no links are needed } }); } @@ -120,6 +126,19 @@ jQuery(document).ready(function ($) { $('#sort-order').on('change', function () { triggerFiltering(); }); + + + // Handle pagination click + $(document).on('click', '.pagination a', function (e) { + e.preventDefault(); + + // Extract the page number from the link + let pagedMatch = $(this).attr('href').match(/paged=(\d+)/); + let paged = pagedMatch ? pagedMatch[1] : 1; // Default to page 1 if no match is found + + // Trigger filtering for the selected page + triggerFiltering(paged); + }); }); document.addEventListener('DOMContentLoaded', function () { @@ -148,15 +167,4 @@ document.addEventListener('DOMContentLoaded', function () { }); } }); - - // Handle pagination click - $(document).on('click', '.pagination a', function (e) { - e.preventDefault(); - - // Extract the page number from the link - let paged = $(this).attr('href').match(/paged=(\d+)/)[1]; - - // Trigger filtering for the selected page - triggerFiltering(paged); - }); }); diff --git a/assets/style.css b/assets/style.css index 7320f91..4e25046 100644 --- a/assets/style.css +++ b/assets/style.css @@ -130,6 +130,13 @@ margin-top: 20px; } +.pagination ul { + list-style: none; + display: flex; + gap: 8px; + padding: 0; +} + .pagination a, .pagination span { margin: 0 5px; diff --git a/resource-filter.php b/resource-filter.php index 21d790f..f3fa0f2 100644 --- a/resource-filter.php +++ b/resource-filter.php @@ -178,14 +178,14 @@ class ResourceFilterPlugin { 'format' => '?paged=%#%', 'prev_text' => '«', 'next_text' => '»', + 'type' => 'list' ]); - - if ($pagination_links) { - echo '