I have a successful Fishpig integration to magento 2.
Now I need to get the blog page to display most recent post on each category.
Ex: If I have 5 categories (without showing uncategorized category), I need to display most recent post from each category.
How can I do this with fishpig?
I tried modifying list.phtml file, from FishPig/WordPress/view/frontend/templates/post. So far I can only get the most recent posts from any category (if I have most recent posts in one category, I get them. not most recent post from each category).
This is the code I've got so far..
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance() ?>
<?php $posts = $objectManager->create('FishPig\WordPress\Model\ResourceModel\Post\Collection')
->addPostTypeFilter('post')
->setOrderByPostDate()
->addIsViewableFilter()
->setPageSize(5)
->load();
?>
<?php if (count($posts) > 0): ?>
<ul>
<?php foreach($posts as $post): ?>
<li>
<a href="<?php echo $post->getUrl() ?>"><?php echo $this->escapeHtml($post->getPostTitle()) ?></a>
<?php if ($image = $post->getFeaturedImage()): ?>
<a href="<?php echo $post->getUrl() ?>">
<img src="<?php echo $image->getAvailableImage() ?>" src="<?php echo $this->escapeHtml($post->getPostTitle()) ?>" />
</a>
<?php endif; ?>
<p><?php echo $post->getPostExcerpt(40) ?></p></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
How should I modify this to achieve what I need? Please help