jcadima
2/6/2017 - 5:29 PM

Recent Wordpress Posts to Magento

Recent Wordpress Posts to Magento

https://fishpig.co.uk/magento/wordpress-integration/recent-posts-block/

http://magento.stackexchange.com/questions/93419/how-to-get-the-featured-image-in-wordpress-post-view-fishpig-integration-dynamic



<?php $posts = Mage::getResourceModel('wordpress/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->getPermalink() ?>"><?php echo $this->escapeHtml($post->getPostTitle()) ?></a>
				<?php if ($image = $post->getFeaturedImage()): ?>
					<a href="<?php echo $post->getPermalink() ?>">
						<img src="<?php echo $post->getAvailableImage() ?>" src="<?php echo $this->escapeHtml($post->getPostTitle()) ?>" />
					</a>
				<?php endif; ?>
				<p><?php echo $post->getPostExcerpt(40) ?></p></li>
		<?php endforeach; ?>
	</ul>
<?php endif; ?>



The code above will generate a collection of your 5 most recent blog posts 
and loop through them and display them.