Yes, use caching. But even with caching you should rethink what you are actually doing because the cache for page/2 should change every time you publish a new post which might make caching pointless depending on the amount of traffic to that page.
You should probably rethink what you are trying to achieve there, why 54 and not less? 54 images on one page is a lot and the page will be slow not only because of the HTML generation but also because fetching the images will take time.
Related Posts:
- Get the number of posts from the current page results
- get_the_title($postID) OR get_the_title()?
- WP Pagination on Posts Search Results Page resulting from AJAX WP Query
- Five posts from a category in footer
- Slow page loads due to WordPress Core Query
- How to increase load time of an archive/search page (WP_Query)
- Paginate pages with dynamic query
- filter posts by meta key with pagination
- Trouble Making WP_Query paged
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Showing the correct number of posts_per_page when avoiding the use of post__not_in
- Show number of posts AND number on current page (cannot make it work)
- When to use WP_query(), query_posts() and pre_get_posts
- Find out total number of pages in global query on archive page?
- WordPress Pagination Not Working – Always Showing First Pages Content
- get_query_var function not working at all
- get_query_var( ‘paged’ ) not working outside of homepage
- Pagination returns 404 after page 20
- Combining two wordpress queries with pagination is not working
- next_posts_link not working for loop called with ajax
- How to know which one is the main query?
- Pagination shows 404 after a certain number of pages
- get query’s query string
- Query with pre_get_posts to get pagination
- Pagination is not working using WP_Query
- Transient pagination not working properly
- Woocommerce custom loop to show all the products [closed]
- Pagination 404 errors for author posts query on author.php
- Pagination problem after WP_Query with tag filtering
- Multiple WP_Query loops with Pagination Not Working
- Posts loop with pagination on a single post page
- Custom pagination with WP_Query generating 404 error
- Query post with meta_query where date is not in future
- Next/Prev posts on same page
- Improve wp query perfomance on large db
- How to query a custom post type with a taxonomy filter but display post type archive page?
- WP_Query last five posts, simply ordered by meta_value
- Create A Loop With A Variable Number of Posts For Each Bootstrap Row?
- WP_Query “OR”: Find posts by ID, Name or Post Title?
- Change query_posts to WP_Query in page but does not work
- The pagination on index.php doesn’t work on a first page
- Serve specific “template” page at any URL that ends in its slug
- WordPress pagination not working using WP_Query
- Display tags with random thumbnail from selection of posts with that tag
- how to make members list directory through wordpress post custom meta key.
- posts_per_page not working for first page of pagination
- Loop Performance > JSON files vs. WP_Query vs. REST API
- Add class to first post in custom loop using post_class filter
- Custom post type archive pagination query issue
- How to get all post except particular category without breaking the paging
- How do I rewrite this loop as a new WP_Query style-loop?
- Pagination only won’t work in author template
- Filter Custom Taxonomy Posts
- How to provide meta_key array to wp_query?
- wp query error while paging the posts
- Order post type by sum of two custom fields
- Use WP_Query or query_posts() or get_posts() for optimizing a site?
- Show single posts date, in a page of posts
- Custom Homepage Pagination using WP_Query
- Custom template for password protected page
- WP_Query Class custom field parameters
- Add AJAX “Load more” on custom query block
- Ajax (jquery) wp_query pagination returns -1
- Elementor posts custom query based on tag [closed]
- Function the_posts_pagination() not compatible with WP_Query arguments
- Facing problem with tax_query results
- Pagination of custom page with custom fields query
- pre_get_posts pagination not working
- Pagination not working on archive.php template?
- Custom query to retrieve oldest post and retrieve others with date interval
- Pagination inside the blog page not working
- Pagination on archive.php not working?
- Unusual high query of user meta data
- How to query most recent post for each author?
- Custom Query Pagination not working on static front page
- WP_Term_Query->get_terms() very slow query for WordPress filter
- WordPress search page pagination displaying but not functional
- How to search CPTs in draft using get_page_by_title()
- Paginated Post List on Front Page
- Custom WP_query and integrating into theme file
- Pagination in WP_Query?
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- Website goes slow down after importing long database
- Archive – Show Page Month Headers
- Query post Pagination Problem
- Pagination for custom query throws 404 errors on last pages [duplicate]
- How to organize a WP_Query’s list of posts by category and display category title?
- How to add archives (with pagination) to page template?
- query post based on comparison
- No content found on page 2 of pagination with 1 post per page
- Ordering Custom WP_Query loop by meta key value with pagination
- Multiple loop for “featured” items returns wrong posts
- Pagination in custom query not working [duplicate]
- paginate_links() on page (shortcode output)
- Query Posts to fetch Posts with Unique Tag
- query_posts problem – need help
- Paginate wp_query while utilizing post__not_in
- Get next post when using pagination with WP_Query?
- Pagination showing same posts despite changing page
- Pagination on custom post type not working