我无法过滤掉与posts.phtml 块中的产品相关的相关类别帖子(使用Fishpig)。我尝试使用以下解决方案来获取帖子:
Fishpig Wordpress Magento 发布问题
像这样:
$categoryId = Mage::registry('wordpress_category')->getId();
$recentPostCollection = Mage::getModel('wordpress/post')->getCollection()
->addIsPublishedFilter()
->addCategoryIdFilter($categoryId)
->setOrder('post_date', 'desc')
->setPageSize($numPostsToShow)
;
然后修改原始的相关帖子块:
<?php //$posts = $this->getPosts() ?>
<?php $posts = $recentPostCollection; ?>
<?php if (count($posts) > 0): ?>
<div class="block block-blog block-recent-posts">
<?php if ($title = $this->getTitle()): ?>
<div class="block-title">
<strong><span><?php echo $this->__($title) ?></span></strong>
</div>
<?php endif; ?>
<div class="block-content">
<ul id="<?php echo $this->getListId() ?>">
<?php foreach($posts as $post): ?>
<li class="item">
<?php $image = $post->getFeaturedImage(); ?>
<img src="<?php echo $this->htmlEscape( $image->getAvailableImage() ) ?>" ?>
</li>
<?php endforeach; ?>
</ul>
<script type="text/javascript">decorateList('<?php echo $this->getListId() ?>')</script>
</div>
</div>
<?php endif; ?>
而且,这行不通。当我将静态数字放入 $categoryID 时,我至少可以将数据放入 $recentPostCollection,但循环不适用于该数据结构......任何帮助都会很棒!谢谢。