Thursday 4 July 2013

Magento - How to display blog posts with featured images on magento homepage


- First we need to integrate the fishbig in my magento site.(fishbig used for integrate wordpress with magento).

- When we integrate fishbig with magento we can have one folder "wordpress" in the template folder.(path:- app\design\frontend\base\default\template).

- in that we can create our custom folder like "home". in that we need to create one .phtml file called "slider.phtml".

- the followings code returns the post name, post featured image etc...



<?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; ?>

- Then call this template in home page slide section like,

<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>

Reference Link: How to display blog posts with featured images on magento homepage?

12 comments:

  1. Hi Ravichandran ,

    Nice post,thanks for sharing this information.Looking forward for more interesting posts like this.







    Magento Developers

    ReplyDelete
  2. Absolutely fantastic topic! Great blog. Thanks for taking the time and writing this.

    ReplyDelete
  3. There some very impressive points in your blog. I must appreciate your excellent work. I find the blog post very interesting and moreover very informative.
    magento webshop

    ReplyDelete
  4. I get a lot of great information from this blog. Thank you for your sharing this informative blog. Recently I did PHP course at a leading academy. If you are looking for best PHP Training Institute in Chennai visit FITA IT training academy which offer real timePHP Training in Chennai.

    ReplyDelete

  5. Hi, Thanks for sharing this valuable blog.I was really impressed by reading this blog. I did HTML5 Courses in Chennai at reputed HTML5 Training Institutes in Chennai. This is really useful for me to make a bright future in designing field.

    ReplyDelete
  6. i really like this article please keep it up.
    newizze

    ReplyDelete
  7. Hi, interesting to read this blog about magentomagento training in chennai

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete