<?php
$postCatCollection = $this->helperData->getPostCollection("category", 9, 4);
$postCatCollection->addAttributeToSelect("*")->getSelect();
?>

    <?php if ($postCatCollection && $postCatCollection->getSize()): ?>
    <div class="instapic"> 
        <?php
            $count = 0;
            $end = 3;
            foreach ($postCatCollection as $catpost): ?>  

                <?php $count++; ?>   

   				<?php if ($catpost->getImage()): ?>

                <a href="<?= $catpost->getUrl() ?>"><img src="<?= $block->resizeImage($catpost->getImage(), '500'); ?>" alt="<?= $block->escapeHtml($catpost->getName()); ?>" alt="" /><h5><?= $block->escapeHtml($catpost->getName()); ?></h5></a>
                 <?php endif; ?>   

	    <?php if ($count == $end) { break; } ?>
            <?php endforeach; ?>
    </div>
    <?php endif; ?>
