1

I have the FishPig wordpress/magento integration.

I'd like to be able to display a blog post in a category much like you can display a native static CMS block.

I had expected that the associated blog post feature achieved this, is that the case?

If not how can this be achieved?

closed as off-topic by Fabian Schmengler, Khoa TruongDinh, Rajeev K Tomy, Siarhey Uchukhlebau, Raphael at Digital Pianism Jan 12 '17 at 9:02

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about third-party modules are generally off-topic because the scope of functionality and code are not available. For more information, see this meta post/answer." – Fabian Schmengler, Khoa TruongDinh, Rajeev K Tomy, Siarhey Uchukhlebau, Raphael at Digital Pianism
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Is this Magento 1 or 2? – Bobadevv Jan 11 '17 at 16:30
  • It's Magento version 1.9.3.1 – Arjun Sol Jan 11 '17 at 16:43
0

You can update the app > design > frontend > your_package > your_theme > template > catalog > category > view.phtml template and add code to display a post, the code below will show your blogs most recent post.

You can filter this to display a post from a specific category or any of the other filter Fishpig offers.

<?php
$posts = Mage::getResourceModel('wordpress/post_collection')
    ->addPostTypeFilter('post')
    ->setOrderByPostDate()
    ->addIsViewableFilter()
    ->setPageSize(1)
    ->load();
?>

<?php if (count($posts) > 0): ?>
    <ul>
        <?php foreach($posts as $post): ?>
            <li>
                <a href="<?php echo $post->getPermalink() ?>"><?php echo $this->escapeHtml($post->getPostTitle()) ?></a>
                <?php if ($image = $post->getFeaturedImage()): ?>
                    <a href="<?php echo $post->getPermalink() ?>">
                        <img src="<?php echo $post->getAvailableImage() ?>" src="<?php echo $this->escapeHtml($post->getPostTitle()) ?>" />
                    </a>
                <?php endif; ?>
                <p><?php echo $post->getPostExcerpt(40) ?></p></li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

Toggle post per category

If you want to be able to toggle the post to show per category you can add a custom Yes/No category attribute, then write some logic if this is set to yes display a post using the above code.

  • Will this not effect all magento categories? – Arjun Sol Jan 11 '17 at 16:43
  • I have added some info how I would enable you to toggle this per category – Bobadevv Jan 11 '17 at 17:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.