PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 9, 2022

[FIXED] How to display blog posts with featured images on magento homepage?

 July 09, 2022     magento, posts, wordpress     No comments   

Issue

I have integrate the fishbig in my magento site.(fishbig used for integrate wordpress with magento). now the posts are displayed fine.

now i need to get postname, postdate, post featured image and post link for displaying in the home page as slide. how can i get that?


Solution

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>


Answered By - Ravichandran Jothi
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing