1. Home
  2. Knowledge Base
  3. Posts Table Pro
  4. Posts Table Pro Shortcode Options
  5. Lazy load option for tables with many posts

Lazy load option for tables with many posts

The lazy load option in Posts Table Pro uses AJAX to speed up the posts table for sites with large numbers of posts.

What is lazy load?

By default, Posts Table Pro will load all of the data into the table when it is first displayed on screen. If you have more rows than can fit on a single page of results (e.g. you are showing 20 rows per page and you have 30 results) then it will create multiple pages with pagination links at the bottom of the table. However, all the posts on all the pages are loaded at the same time.

For large numbers of posts, this can cause a hit on performance as all matching posts need to be fetched from the database and then formatted by the table plugin. This can cause slower page load times and – for very large data sets – may even result in a server or database error when attempting to load the table.

If you’re worried about performance, then we recommend enabling the “lazy load” option. This will load the posts one page at a time via AJAX rather than all at once. As the user navigates between the pages of results, they will see a “Processing” message displayed (briefly) while the next posts are loaded from the database.

How to enable lazy load

To enable lazy load, add lazy_load="true" to the Posts Table Pro shortcode.

Example: [posts_table lazy_load="true"]

Limitations of lazy load

Enabling lazy load means that all post fetching, searching, and sorting is handled by the server rather than in the browser. This leads to some limitations with tables that use lazy load:

  • The search box will only search within the title and content columns.
  • Users can only sort the table by the title, author and date columns. (You can still use the sort_by option to sort the table by any column when it first loads.)
  • The ‘search_on_click’ feature is disabled, so users can’t click on a category or tag to filter the table.

These limitations are due to the way in which WordPress itself interacts with the database, and are unavoidable.

Please note that the above limitations do not affect the filter dropdowns above the table. When a user clicks on a filter, the plugin will fetch all posts matching that filter from the database.

Was this article helpful?

Related Articles