Skip Navigation

[Resolved] How to increase the limit of my recent added contents than 50

This support ticket is created 3 years, 10 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.

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 17 replies, has 2 voices.

Last updated by ramez-refaatG 3 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#1659515

Tell us what you are trying to do?
I want to show more than 50 newest contents, the limit & offset has only 50 or will show all...I don’t like to show all, but I want to make it the number I want e.g. 100.
hidden link

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?
hidden link

#1659869

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

The UI doesn't let you select a number greater than 50, so you will need to add a little code snippet to override whatever option you choose.

In Toolset > Settings > Custom code you can add a snippet like so:

function tssupp_filter_query( $view_args, $view_settings, $view_id )  {
    
  if ( in_array( $view_id, array( 123 ) ) ) { // Edit ID
    
    $view_args['limit'] = 100;
  }
  
  return $view_args;
}
add_filter( 'wpv_filter_query', 'tssupp_filter_query', 101, 3 );

You just need to edit the ID of the View to modify.

#1661895

Thanks...I did change the ID to the number 7784 which is the View's number.
But there're errors appeared:
1. Snippet "updates_increase" has been updated.
2. There was error when trying to re-run the snippet:syntax error, unexpected '$view_args' (T_VARIABLE) in /home/lifechan/public_html/wp-content/toolset-customizations/updates_increase.php on line 10 A problem occurred when executing snippet "updates_increase". The result of include_once is: ""

The code I edited is here:
========================
<?php
/**
* New custom code snippet.
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
function tssupp_filter_query( $view_args, $view_settings, $view_id ) {

if ( in_array( $view_id, array( 123 ) ) ) { 7784

$view_args['limit'] = 100;
}

return $view_args;
}
add_filter( 'wpv_filter_query', 'tssupp_filter_query', 101, 3 );

========================
Please help to make it without errors, I'm not a developer so I might made something wrong.
Thanks.

#1662737

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

You replaced the comment indicating the line to edit, rather than changing the ID itself.

Sorry if I wasn't clear, you need to replace "123" in my sample code with "7784", the part // Edit ID is just a comment.

#1662801

Okay thanks a lot...I applied the code as you said...the error disappeared, but still the table shows 50 posts only.
I cleared the cache for this page but still 50 only...does the Toolset have its own plugin? How can I clear it?
Or what's the mistake in the code?

#1662859

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Screenshot 2020-06-15 at 08.39.13.png

Can you go to Toolset > Settings > Front-end Content and turn on the debug mode (Full) for Views?

Then when you visit the page with the View a new window will appear (you may have to click a browser option to allow the site to create pop-ups).

You can expand the wpv_filter_query section to see the View query arguments, where you should see the limit argument set to 100, as you can see in my screenshot.

If you don't then it means the code you added didn't get applied to this View.

Either the View ID is wrong, or the code isn't active, or—less likely—something else is interfering.

You said you cleared the cache already, you mean the button next to the View when you list the Views at Toolset > Views, yes?

#1662981

No I cleared the Main Cache Plugin for the whole site.
Beside each view there’s no caching: In the Table’s column it says: Not Cached
I don’t know how to turn on the cache for Toolset.

I tried the Debug as you said, also the pop up is allowed but still nothing appears.
Please help.

#1662989

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Can I get credentials to check your site myself?

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site.

Can you also confirm the url of where I can see the problem?

#1663035

Notice please the site shows blank pages on activating them Snippets
So please keep the page to turn Activate or Deactivate the Snippet
Thanks

#1663179

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

It's not so easy for me to be sure of what I'm looking at on the site.

I tried to test activating the code snippet and it didn't appear to have any effect, and the debug mode isn't working for some reason, there are no pop-ups.

I temporarily edited the View itself (View ID = 7784 accoring to your code above, with slug of "recent-content") and changed the limit setting to just 5 posts, but it had no effect on the front end, it still shows 50 posts.

So either this isn't the correct View that corresponds to the page you linked to, or something is interfering.

So I would need access to a staging site for testing, to check with other plugins disabled etc. whether the View settings work.

Do you have a staging site available for testing?

#1663195
E09DC1E1-540C-4F30-B331-122727D2B4A5.png
321ABAF1-739A-4114-A4F9-36627DCA2FCB.png

It worked fine now seems cache I don’t know from where.
Also the page shows 5 posts only.
We don’t have staging site.
Please return the number of posts after finishing it’s live site.
Thanks.

#1663437

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

I did some testing and can see that the problem happens because of WPML, I can reproduce the same thing on a local test site.

So, I'm escalating this so that we can fix that, and you may also like to know that we've created a ticket to update the UI for the limit settings to that you can enter any number rather than choose from the range provided in the dropdown.

I'll let you know when I have some feedback about how to resolve the problem related to WPML.

#1681451

HI. Any news? I'm waiting ...
Thanks

#1681637

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Sorry for not getting back to you sooner, a colleague comments a minor problem with the code I shared with you.

The code should read as follows:

function tssupp_filter_query( $view_args, $view_settings, $view_id )  {
     
  if ( in_array( $view_id, array( 7784 ) ) ) { 
     
    $view_args['posts_per_page'] = 100;
  }
   
  return $view_args;
}
add_filter( 'wpv_filter_query', 'tssupp_filter_query', 101, 3 );

If you prefer I can go into your site and make sure it is correct, or you can go ahead and update the code snippet yourself.

If you would like me to I'll need to set up a private reply to get updated credentials from you (I tried to log in but the previous credentials are no longer valid).

#1683267

Still an error appeared....please the best way is to make it in the choices in the user interface.
Thaks.

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