How to limit the number of records in the YARPP plugin?

To output a block of similar records using the wordpress plugin YARPP. Do it through custom code in the output file, which is carried in the theme folder. Here's the code:
<?php if ($related_query--->have_posts()):?>

 <?php while ($related_query--->have_posts()) : $related_query->the_post(); ?>

 the <li>Here miniatures, titles, etc.</li>

 <?php endwhile; ?>


Tell me how to limit the number of entries to be listed in this block a certain number? For example, to display only 6 records?
July 2nd 19 at 18:20
1 answer
July 2nd 19 at 18:22
Solution
<?php if ($related_query--->have_posts()):
$i = 0;
?>

 <?php while ($related_query--->have_posts()) : $related_query->the_post(); 
$i++;
 if ($i > 3) {
break;
}
?>

 the <li>Here miniatures, titles, etc.</li>

 <?php endwhile; ?>
Thank you very much! What you need! - Mary.Effert commented on July 2nd 19 at 18:25

Find more questions by tags WordPress