Last active
November 17, 2017 14:01
-
-
Save ScarletPonytail/6a4bbb40027d9b741091f6ea611294d2 to your computer and use it in GitHub Desktop.
Magento - [FishPig Wordpress Plugin] Adding Recent Blog Posts to a Magento Template File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 $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; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment