Skip Navigation

[Résolu] How to add a « Load more » button

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
On a page with a View listing posts how is it possible to add a Load more button that adds to the existing results rather than replacing them.

Solution:
It is possible to simulate such behaviour:

- make a View with infinite scroll for pagination
- in the settings set a large negative scroll tolerance, e.g. -500
- insert a next page button

That should work, with the caveat that the infinite scroll will still be triggered if the user reaches the very bottom of the screen even if they did not press the "load more" button.

Relevant Documentation:
https://toolset.com/course-lesson/creating-a-view/

Future plans
Toolset development team already has this feature on our todo list. We'll add it as soon as we can and then announce on our blog and newsletter.

This support ticket is created Il y a 4 années et 12 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 5 réponses, has 2 voix.

Last updated by arisG Il y a 4 années et 12 mois.

Assisted by: Nigel.

Auteur
Publications
#1243133

Hello,

We use a WordPress Archive with infinite scroll enable but with "Infinite scrolling tolerance, in pixels" setting to -500 in order to prevent auto scroll and add a load more button.

Reference : https://toolset.com/forums/topic/load-more-button-3/

We have seen strange behave. In some developers, infinite is disabled and to some other infinite works.

We have tried the following without success.

- Incognito chrome
- Different browsers
- Disable Litespeed caching
- Disable Cloudflare

Does Toolset have any caching mechanism by itself?

#1243495

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

Toolset includes quite a bit of internal caching to speed up queries for post meta and for posts, but nothing that should influence this. You'll also notice in the advanced settings for the pagination where you added the -500 tolerance settings to cache and preload pages.

I just tested this solution locally and didn't experience any problems, although because of the large footer on the test site using twentynineteen theme I had to change the tolerance to a bigger negative number, i.e. 5000.

Can you clarify what doesn't work?

I set that tolerance so that the infinite scroll itself never works, only the load more button works, but you could choose a tolerance level where if you scrolled a little bit past the results there would be no infinite scroll triggered and it would need to be triggered manually with the load more button.

Could that be the problem, that on some different screen sizes the load more button works as well as infinite scroll, and on others only the load more button works?

#1243958

For Testing reasons we have done the following :

- we have created a new clean WordPress Archive for testing.
- we have added in WordPress setting, "Your homepage displays" as Latest Posts
- we have added "Infinite scrolling tolerance, in pixels" setting to -10000
- we have added a Load More button with <div class="load-more">[wpv-pager-next-page force="true"]Load more...[/wpv-pager-next-page]</div>

In some devs infinite works from the first page and in one specific dev in first-page use Load More button, in second page infinite and then only infinite. I can't understand what is going on.

I can provide Credentials in our Demo environment if you want.

#1243959

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

Sure, let me see what you mean on your site, I have set up a private reply.

Please be sure to detail each place where I should be testing this and what I should expect to see in each case.

#1243984

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+01:00)

On your site I found that the load more button works on both pages, but that the infinite scroll also happens automatically.

But only when scrolling to the very bottom of the page and actually hitting the bottom.

You have a very small footer, so that is easily done.

On my local test site where I'm using twentynineteen the default footer is quite large, which is why I wasn't noticing the same result. So one solution is to make a bigger footer so that the infinite scroll isn't accidentally triggered.

I don't know whether this reflects browser behaviour, or is related to how this is coded.

But I know that it's not a bug, as adding infinite scroll it is expected that you would use infinite scroll, whereas you are trying to trick Views into providing a load more button, functionality which isn't currently available.

So the best solution—apart from the "hack" of making a longer footer—would be to request support for a Load More button, which you can do here: https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

#1244055

So, officially is not supported the Load More Button as I Understand. We just try to simulate the functionality with workarounds. I have read in toolset support forum that Load More functionality is already open as a feature request.

We have made a longer footer but again the infinite scroll triggered in some cases. Also, we noticed different behavior per developers. It's something that we can't rely on it.

We managed to resolve the problem by disabling the auto load more with the following code we found in the forum

jQuery(function($){
WPViews.view_pagination.is_infinite_triggable = function(view_layout){return false; }
});

Thank you for your help.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.