Recently I was working on a website for a small business client. They wanted a simple system to allow them to easily update a section of their website. Since it was a small website, I wanted to accomplish this without putting too much time but still creating something user-friendly and easy to use that can get the job done. The main site was made using CodeIgniter. So we decided to create a WordPress blog for the client where they could put their content and I would pull that content inside their CI website. Here’s how:
First of all, install WordPress in a folder called blog in your website. It would be located at the top level directory of the website. So it would be alongside the system folder of the CI installation. If you already have a DB for your site, have WordPress add tables to that same DB with a prefix to make things simple (although this is not a requirement).
Once that’s done. All you have to do is add the following line in the at the top of your CodeIgniter’s index.php file. Change the path to wp-blog-header.php as needed to point to your wordpress’s root directory.
One you get that dialed in, rest is pretty straight forward. All of WordPress’ native API functions should now be accessible to you. So you could throw in a WordPress loop in any of the CI views like for example:
…and a sidebar on the same which which would list out all the tags and categories to select from:
That’s it! This would allow us to browse all the blog entries without leaving the CI site. Other helper functions can also be found in WordPress’s documentation which can assist you in integrating the design.