Question

This should be simple, but for some reason it is not. I simply want to be able to load in my own template file and have access to the $this->getPosts() method.

I have tried:

<block type="wordpress/post_list" name="blog_header" template="unleaded/fishpig/header.phtml"/>

and then in my template:

<?php $_posts = $this->getPosts() ?>
<?php foreach ($_posts as $_post) : ?>
     <?php echo $_post->getAuthor() ?>
<?php endforeach ?>

This does not work. Looking at the main List.php block file, the collection is returned based on a "wrapper", but I can't seem to find what that is.

Does anyone else have a code sample for getting a post list in any template for Magento?

Was it helpful?

Solution

Was a simple matter of grabbing the block first. There's other ways, but this worked for me.

<?php $_block = $this->getPostListBlock() ?>
<?php $_posts = $_block->getPosts() ?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top