Magento 2 is the most popular and perhaps the best ecommerce platform out there. However, to ensure that your Magento 2 store is successful, you need to attract a lot of traffic to it. There are many ways to drive traffic to your store but nothing works better than a blog. And we all know which platform is the best for a blog: WordPress, of course!
If you are thinking, “is it possible to integrate WordPress in Magento 2?” the answer is: Yes, it is possible!
So in this tutorial, I will teach you how to add WordPress in Magento 2. For this, I will use FishPig’s awesome Magento WordPress Integration module. Let’s Start!
- Go to WordPress Official and Download the latest version.
- Upload the zip folder in your Magento 2 root directory.
- Extract the archive folder and you will get a folder named wordpress
- Rename the wordpress folder as wp.
Now open the web browser, insert your Magento store URL, and add wp/ at the end of the URL. For example http://www.example.com/wp/
The WordPress installation screen will open. Click on Let’s go!
Insert the database details, enter your existing Magento database details and click on Submit. For details, go to app/etc/env.php from your Magento 2 store directory.
Note: You can also create a new database for your WordPress and add the details.
If you get the following error (shown in the image below), just create a wp-config.php file in your wp directory. Now copy the code that appears on the screen and paste it back into a wp-config.php file. Now just click on Run the Install.
Now you should be on the Welcome page. Enter your WordPress details and click on Install WordPress.
Install Magento WordPress Integration Module
Go to the app folder from the root directory of your store and create directories: code/FishPig.
Download the FishPig Magento WordPress Integration module and extract the archived folder. You will get the folder magento2-wordpress-integration-master; rename it to WordPress. Upload this WordPress folder in your Magento store at app/code/FishPig. The final structure will look like this:
Now run these commands in the root directory of your store:
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
Go the admin panel of your store and click on WORDPRESS option from the panel on the left. Make sure it is enabled and the path is wp as shown:
Note: You will see some warning messages, but they will resolve automatically after following the next steps.
Copy FishPig Theme
Copy wptheme folder from app/code/FishPig/WordPress from the root directory of your store:
Now go back to your root directory and paste wptheme in wp folder at location wp/wp-content/themes. Rename the wptheme folder as fishpig:
Configuration in WP
Login to your admin panel of your WordPress and then go to Settings → General. Change the Site Address (URL) from http://example.com/wp to http://example.com/blog.
Now just click on Save Changes:
Now go to Appearance → Themes and activate the FishPig Theme:
And you’re done! Open your store’s frontend by adding blog at the end of its URL like http://example.com/blog and you will see your WordPress blog successfully integrated into your store:
Go to WORDPRESS from the admin panel of your Magento 2 store and you won’t see the warnings messages anymore: