We all know that Magento is the best platform for eCommerce and WordPress is the best for blogging.
If you already have a user-friendly Magento eCommerce website and want to boost SEO for your product keywords in order to achieve top search rank, integrating a WordPress blog with Magento is the best way. Any professional SEO service company provider will advise you the same.
Your next question would be, Is that possible to integrate your WordPress blog with your Magento website? The answer is yes and it’s not that difficult.
In this article, we have provided step by step guide on how to integrate a WordPress blog with your Magento 2 store.
Magento WordPress Integration
First, we need to download the extension and use it for making connections between Magento and WordPress.
We will be using a free extension of FishPig Magento WordPress Integration downloadable from here which has good features to connect Magento and WordPress.
Once the archive is downloaded, go to your Magento root directory and you need to extract the files from the archive there. After the extraction it will show like below:
After that, you need to enable the extension and clear the cache so that the blog integration is available on your Magento store to use.
For this, you have to run commands from the terminal using SSH access. Log in to your Magento store SSH account and go to the Magento root directory and run the below commands:
php bin/magento module:enable FishPig_WordPress php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento cache:clean php bin/magento cache:flush
Once finished executing these commands successfully, you need to go to your Magento store admin configuration to Enable the Blog link and set the path of your WordPress installation directory.
Go to Admin -> Store -> WORDPRESS
Make sure that the path of your WordPress installation is relative to your Magento root.
The next step for your WordPress blog integration with Magento 2 is to ensure that correct settings are applied in your WordPress to link to the Magento 2 integration.
Also, your WordPress blog should be installed and working under the sub-directory of your Magento 2 root directory which you have entered in the above step.
Go to your WordPress Admin -> Settings -> General. Here you need to update the Site Address to “/blog” so that WordPress front pages can be accessed with that URL.
Now save the changes and you can check your integration of WordPress blog with Magento 2 is complete.
Go to your Magento 2 store URL and add “/blog” there to open your WordPress blog in your Magento store. Discuss with our WordPress developers if you are facing any issues.
Display Recent WordPress Posts in Magento 2
You can easily show a list of your recent blog posts to your Magento 2 site by using the code below.
This code will generate a collection of the 5 recent posts on your blog and loop through them to show those.
Here’s a simple example that uses the object manager:
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance() ?>
<?php $posts = objectManager->create(‘FishPig\WordPress\Model\ResourceModel\Post\Collection’)
<?php if (count($posts) > 0): ?>
<?php foreach($posts as $post): ?>
<a href=“<?php echo $post->getUrl() ?>“><?php echo $this->escapeHtml($post->getName()) ?></a>
<?php if ($image = $post->getFeaturedImage()): ?>
<a href=“<?php echo $post->getUrl() ?>“>
<img src=“<?php echo $image->getAvailableImage() ?>“ src=“<?php echo $this->escapeHtml($post->getName()) ?>“ />
<?php endif; ?>
<p><?php echo $post->getPostExcerpt(40) ?></p></li>
<?php endforeach; ?>
<?php endif; ?>
Content marketing is the best way to boost your organic search rank and a blog on your eCommerce website will help you to share useful content about your products with your customers. Review another post on why it is important to have a blog on your ecommerce website.
Still, have any questions? Please contact our Magento 2 experts who are always happy to help.