Improve Query Loop Loading Performance In Editor

When employing multiple query loop blocks with a substantial number of posts per page, the operational speed of the editor may experience a decline. In order to enhance this aspect, we have introduced a filtering mechanism that enables the establishment of an upper limit for the number of posts per page.

Step 1: add the filter

To implement this optimization, you can integrate the provided filter into your setup. Replace the return value of 1 with the desired quantity of posts that you intend to exhibit within your query loop blocks during the editor phase:

add_filter('generateblocks_query_loop_editor_posts_cap', function() {
	return 1; // Adjust this value accordingly

Step 2: change the posts per page to -1 in the query loop block

After integrating the filter, navigate to the page editor in which you encounter sluggish loading speeds. Within the query loop configuration, set the posts per page value to -1. This step enables the filter to identify the specific query loop in question. Consequently, you should observe an immediate reduction in the number of displayed posts within that query loop.

Step 3: change the posts per page back in the query loop block

Once you have noted the positive effect, feel free to revert the posts per page value to align with the desired outcome for the front-end display.