Skip Navigation

[Resolved] Load more article in the same page

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

Problem:

I am having an issue with loading multiple articles on the same page using a Load More button.

Instead of loading the next page below the first, the button opens a second page even though I have an infinite scroll set up.

Solution:

Remove the Pagination block and use the shortcode block with the following shortcode:

[wpv-pager-next-page force="true"][wpml-string context="wpv-views"]Load More Button here ...[/wpml-string][/wpv-pager-next-page]

Make sure to add the block inside the View Output block. If the issue persists, try creating a new view with the authors and check with the Block Editor instead of the classic view.

Relevant Documentation:

https://toolset.com/forums/topic/create-load-more-button-with-toolset-blocks/

This support ticket is created 2 years, 6 months 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.

This topic contains 12 replies, has 2 voices.

Last updated by ferruccioR 2 years, 5 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2551615
Schermata 2023-02-10 alle 11.56.20.png
Schermata 2023-02-10 alle 11.55.47.png
Schermata 2023-02-10 alle 11.55.32.png
Schermata 2023-02-10 alle 11.55.19.png

Hi, following this https://toolset.com/forums/topic/create-load-more-button-with-toolset-blocks/ I'm trying to load multiple articles in the same page but my button opens second page when I click it even though I have infinite scroll set up.

I'm sending you my screenshots of the settings.
To block auto infinite scroll I used this code and it works.

(function ($) {
$(document).ready(function () {

$('.js-wpv-layout-infinite-scrolling').removeClass('js-wpv-layout-infinite-scrolling');

});
})(jQuery);

I have a test site here hidden link. As you can see the button opens a second page while I have to load the second page below the first.

How can I solve this problem?

Thanks for your help.

#2553007

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Would you please remove the Pagination block and instead, use the shortcode block and add the shortcode below?

[wpv-pager-next-page force="true"][wpml-string context="wpv-views"]Load More Button here ...[/wpml-string][/wpv-pager-next-page]

If the issue persists, I'd appreciate it if you could give me the URL/User/Pass of your WordPress dashboard after you make sure that you have a backup of your website.
It is absolutely important that you give us a guarantee that you have a backup so if something happens you will have a point of restore.

Make sure you set the next reply as private.

#2554847

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I checked the website but the information you gave is not the website that you have the link to:

hidden link

Please give me login information for that to be able to check.

Also please make sure you have a backup of the website as I might need to turn off /on plugin or the theme for a possible conflict.

Thanks.

#2557403

Christopher Amirian
Supporter

Languages: English (English )

Screenshot 2023-02-19 at 15.15.12.png

Hi there,

I am not sure how you created your homepage. I tried to understand but it is so complicated.

Instead, I created a test page and implemented the Load More feature:

hidden link

One thing that you need to make sure you do is to add the Flield and Text block and add:

[wpv-pager-next-page force="true"][wpml-string context="wpv-views"]Load More Button here ...[/wpml-string][/wpv-pager-next-page]

And make sure you add the block inside the View Output block. You can click the top burger menu and drag the block to the correct place.

Please check the screenshot.

Thanks.

#2558211
Schermata 2023-02-20 alle 18.02.27.png

Hi Christopher,
the home page is created from the Toolset content template called Home.

I send you my structure. I followed your instructions but it doesn't work.
Also in your example the button is still visible even when you load all posts, while I need to hide it on the last page.

Could you please help me by checking the problem in my model?
Thanks for your help.

#2558645

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I removed the force true attribute and now the load more button is removed when the pages are finished.

But the issue with your homepage is not fixed.

I added a pagination block and deactivated the view cache but the issue persists.

As the same thing works ok on the test page that I created I suggest that you do as follows:

- Go to Toolset > Content Template.
- Hover over the Home content template and click the DUPLICATE link.
- On the duplicated content template remove the other views that you used and keep only the view in question.
- See if it works then.

My guess is that either the other views have conflict and do not allow the workaround to work correctly or the containers but I am not sure and it needs you to be testing that.

If the issue is not that, then I will need to copy your website to our server so that we can investigate more.

Thanks.

#2560925

Hi Christopher,
I did what you suggested.
You can see the new home page made with the Home-test content template, but it doesn't work even if I deleted all other views.
Can we add some code to solve the problem? Let me know.
Thank you.

#2561707

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I moved the website to our server to be able to do some investigation and I found out that the issue is the code that you added int he Fields and Text block inside the View output.

I removed that and instead used the Post Title with Link option and it worked ok:

hidden link

Please check within that code and see what is causing the issue there:

<div class="[wpv-post-taxonomy type='colore-pagina' format='slug']">
  <p class="article-date">
    <span class="argomenti"><b style="color: red;">[wpv-post-taxonomy type="argomento-principale" format="name"]</b>[wpv-view name="altritemi"]</span>
  </p>
  <h3>[wpv-post-title]</h3>
  <span class="blocco-autore">[wpv-view name="nuovoelencoautori"]</span>
</div>

Thanks.

#2567843

Hi Christopher,
Thank you. I noticed that the "newauthorslist" view is the problem. If I insert another view the page works fine.
But I need to have the author list of the main article and I find no other way to show them.
Could you suggest me another solution to do this?
If I put the author field it shows only the first author while I need the list. How can I do it? Thank you.

#2568297

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

I am not sure what you have done in that view as we already deleted the copy of the website on our server.

What I suggest is that you create a new view with the authors and try to check with the Block Editor and not the classic view and see what happens.

Thanks.

#2568665

Hi Cristopher,
I solved the view problem, now you can see it is working fine.
I have only a request.

I have a list of authors separated by coma and I need to hide the last coma of the list.

I added this code and it works fine on the first page:

(function toglicoma()
{
var spans = document.getElementsByClassName('blocco-autore');
var l = spans.length;
for (var i=0;i<l;i++) {
var ele = spans[i].getElementsByClassName('coma');
var lastEle = ele[ ele.length-1 ];
lastEle.parentNode.removeChild(lastEle);

}
return false;
})(jQuery);

But when I click on my load more button the function doesn't work on the second page.

How can I add the function to it?

Thank you so much.

New threads created by Christopher Amirian and linked to this one are listed below:

https://toolset.com/forums/topic/split-how-to-preserve-the-js-to-remove-the-last-comma/

#2568989

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

Since the initial problem that prompted the creation of this ticket has been resolved, may I kindly request that you mark it as "resolved." I will then proceed to split the ticket in order to address the second issue.

By doing this, we can ensure that our tickets remain organized and that we have a clear summary of the issue at hand. This will enable other customers to access information more efficiently if needed.

Thank you for your cooperation and understanding.

#2570269

My issue is resolved now. Thank you!