如何在magento主页上显示包含精选图片的博文?

时间:2012-06-01 11:18:22

标签: wordpress magento posts

我已将鱼网整合到我的magento网站中。(fishbig用于整合wordpress与magento)。现在帖子显示得很好。

现在我需要获取postname,postdate,post featured image和post link以在主页中显示为幻灯片。我怎么能得到那个?

1 个答案:

答案 0 :(得分:1)

当我们将fishbig与magento集成时,我们可以在模板文件夹中有一个文件夹“wordpress”。(path:- app\design\frontend\base\default\template).

我们可以创建像“home”这样的自定义文件夹。因为我们需要创建一个名为“slider.phtml”的.phtml文件。

以下代码返回帖子名称,帖子特色图片等...

<?php $posts = $this->getPosts() 

if (count($posts) > 0): ?>



<?php 
      foreach($posts as $post): ?>
      <?php 

     $image_url = $post->getFeaturedImage()->getFullSizeImage(); // Featured image
          $post_link = $post->getPermalink(); // Post link
          $post_date = $post->getPostDate(); // Post date
          $post_day = date('l', strtotime($post_date)); // Day of Post
          $post_title = $post->getPostTitle(); // Post Title

<?php endforeach; ?> 

<?php endif; ?>

然后在主页幻灯片部分调用此模板,例如

<div class="home_banner">
  <?php
$magento_block = Mage::getSingleton('core/layout');
$blog = $magento_block->createBlock('wordpress/sidebar_widget_posts')->setTemplate('wordpress/home/homeslide.phtml');
$blog->setPostCount(6);
echo $blog->toHtml();
?> 
</div>
相关问题