Hi Alex
Ok so I took a look, I see what you mean.
The issue usually is the way pagination works (and how it detects the current page).
S&F uses its own URL var (sf_paged) for pagination, so sometimes this causes issues like this.
I’m not familiar with beaver builder yet, but is there a way to customise pagination, using something like templates in your child theme? If you could figure that out, I know the code changes we would need to make ๐
—
To explain the issue & solution anyway (it might be useful to beaverbuilder):
Take page 6 of results here – https://yourdevsite/maths-videos/?sf_paged=6
Its clear on your site, the pagination thinks its still on page 1 while S&F has paginated the results to page 6. This is all to do with how your theme (and many others) gets the current page
variable from WordPress, which is then passed on to the pagination function.
A lot themes pagination will look something like:
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => 'page/%#%',
'current' => $current_page,
'total' => $total_pages,
));
Notice, current page is set from this var – get_query_var('paged')
.
To make pagination work correctly in all scenarios, even when the page has been changed dynamically (this could be changed by pre_get_posts
for example), I personally think its best to get the paged var from the query itself, circumventing the need to know the pagination variable name in the URL or if its been altered dynamically.
My solution is to set current page using $wp_query->query_vars['paged']
– so the code sample above would use
global $wp_query;
$current_page = max(1, $wp_query->query_vars['paged']);
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => 'page/%#%',
'current' => $current_page,
'total' => $total_pages,
));
This I think is a more compatible approach to handling pagination in general and allows for more options as a developer (and in this case, would allow your theme pagination to work with S&F custom pagination query var).
Anyway, hope that makes sense, if not, figuring out how to customise beaver builder pagination will be all I need to advise next steps ๐
Best