Skip Navigation

[Resolved] pagination items styles are not updating when going through pages

This thread is resolved. Here is a description of the problem and solution.

Problem:
pagination items styles are not updating when going through pages

Solution:
The pagination shortcodes were not in the right place, and because of the user requirements, we'll need to implement a custom solution. Check this reply https://toolset.com/forums/topic/pagination-items-styles-are-not-updating-when-going-through-pages/#post-1782555

This support ticket is created 4 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by michaelH-21 4 years, 1 month ago.

Assisted by: Jamal.

Author
Posts
#1782553

Thank you. I was able to add this to functions.php and remove the default woo commerce count + pagination. I then went into the Loop Editor for my WordPress Archive and could add [wpv-pager-archive-nav-links] to get the pagination to show up. However, as I click through the pages, it doesn't change the highlighting of which page you're on in the pagination. It is still Page 1 that is highlighted. How can this be updated?

Also, with the results count, I am having an issue finding the proper shortcode to put into the Search and Pagination section so that this can display near my search filters. Can you help?

#1782555

The pagination shortcode was inside of the "Loop Editor" and that way, it can be updated after changing the page using AJAX. It will only work if you deactivate AJAX on the view.

To be able to update the pagination while using AJAX, the shortcodes should go into the "Search and Pagination" section of the archive template.
But this will force the pagination to be at the top of the results, near the archive filters, instead of being at the bottom of the results. We can work around this with a custom Javascript code, that will move the pagination to the bottom of the results.
The solution consists of:
- Putting the pagination shortcode inside a hidden div.
- Creating a target div inside the archive template where we will move the pagination.
- Adding the custom Javascript code to move the pagination, and making sure, it will be executed when the page loads and after each AJAX pagination, also after performing a search.

1. Putting the pagination shortcode inside a hidden div.
We can do this with the following code, note the "pagination-source" class that we will be using in our custom Javascript code, and the style(display: none) to hide it:

<div class="pagination-source" style="display: none;">
[wpv-pager-archive-nav-links previous_next_links="true"]
</div>

2. Creating a target div inside the archive template where we will move the pagination.
We can do this with the following code, note the "pagination-target" class that we will be using in our custom Javascript code:

<div class="pagination-target"></div>

We can put this code in the "Loop editor", or in the "Output Editor" after wpv-layout-meta-html.

3. Custom Javascript code to move the pagination
We can do it with the following code:

// function to move the pagination from .pagination-source to .pagination-target
function my_move_pagination(event, data) {
  jQuery('.pagination-target').html( jQuery('.pagination-source').html() );
}

// When the page first loads
jQuery( document ).on( 'ready', my_move_pagination );

// When AJAX pagination ends
jQuery( document ).on( 'js_event_wpv_pagination_completed', my_move_pagination );

// When an AJAX search ends
jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', my_move_pagination );

I hope this helps. Let me know if you have any questions.

#1783301

My issue is resolved now. Thank you!