I have done fishpig integration with magento2 succesfully but i am not able to show 2 blog post Magento2 home page i created my custom.phtml file and call it to home page but only single post are coming
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance() ?>
<?php $posts = $objectManager->create('FishPig\WordPress\Model\ResourceModel\Post\Collection')
->addPostTypeFilter('post')
->setOrderByPostDate()
->addIsViewableFilter()
->setPageSize(5)
->load(2); ?>
<?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; ?>
I want to show two latest post
The code looks fine, however you don't need to pass the '2' to the load method.
If this code is returning 1 post maybe it is because you only have 1 post in your blog?
The code below will show how many posts you have that are published.