Ecommerce Shopify WordPress Discussion

How to limit the amount of pages shown in my related posts snippet

I use this code to grab posts written by the same author and display them in a slider. However, I would like to limit the maximum amount of posts it grabs to 4, how would I go and change that? Thanks <div class="author-recent-posts small"> <div class="author-recent-posts__slider"> <?php /* $count = 0; */ ?> <?php while ( $query->have_posts() ) : $query->the_post(); ?> <?php /* if($count >= 4) break; */ ?> <?php $thumb = array(get_template_directory_uri() . '/images/music-background.jpg'); if (has_post_thumbnail() ): $thumb = wp_get_attachment_image_src( get_post_thumbnail_id(), 'single-post-thumbnail' ); endif; $thumb = sprintf('style="background-image: url(\'%s\')"', esc_url($thumb[0])); ?> <?php /* $count += 1; */ ?> <div class="author-recent-post-item"> <div class="author-recent-post-item__inner"> <a class="author-recent-post-item__link" href="<?php echo esc_url(get_permalink()); ?>" rel="bookmark"> <span class="sr-only"><?php _e('Read more'); ?></span> </a> <figure class="author-recent-post-item__thumb" <?php echo $thumb; ?>></figure> <div class="author-recent-post-item__header"> <?php the_title('<h3 class="entry-title">', '</h3>'); ?> </div> </div> </div> </div> </div> I'm not sure where to start
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.