私のmagentoサイトにfishbigを統合しました(wordpressとmagentoの統合に使用されるfishbig)。投稿が正常に表示されるようになりました。
ホームページにスライドとして表示するために、投稿名、投稿日、注目の画像の投稿、リンクの投稿を取得する必要があります。どうすればそれを取得できますか?
fishbig を magento と統合すると、テンプレート フォルダーに「wordpress」フォルダーを 1 つ作成できます。(path:- app\design\frontend\base\default\template).
「home」のようなカスタム フォルダを作成できるという点で。そのため、「slider.phtml」という .phtml ファイルを 1 つ作成する必要があります。
次のコードは、投稿名、投稿の注目の画像などを返します...
<?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>