How To Integrate WordPress Blog With Magento 2 Store

How To Integrate WordPress Blog With Magento 2 Store

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:

Magento WordPress Integration

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.

Have a project in mind?

Lets talk about it

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

Magento store admin configuration

Make sure that the path of your WordPress installation is relative to your Magento root.

WordPress Setup

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.

WordPress Setup

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.

WordPress blog in your Magento store

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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance() ?>
<?php $posts = objectManager->create(‘FishPig\WordPress\Model\ResourceModel\Post\Collection’)
->addPostTypeFilter(‘post’)
->setOrderByPostDate()
->addIsViewableFilter()
->setPageSize(5)
->load(); ?>
<?php if (count($posts) > 0): ?>
<ul>
<?php foreach($posts as $post): ?>
<li>
<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()) ?> />
</a>
<?php endif; ?>
<p><?php echo $post->getPostExcerpt(40) ?></p></li>
<?php endforeach; ?>
</ul>
<?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.

Parth Patel, a skilled E-commerce Consultant and co-founder of Icecube Digital, dedicates his time to producing straightforward yet invaluable content. With a sharp attention to detail and a passion for innovation, Parth focuses on Magento, WordPress, Shopify, and other platforms in his commitment to advancing e-commerce solutions.

Leave a Reply