CodeIgniter integration with WordPress

featured image for WordPress and CodeIgniter integration

Is CodeIgniter integration with WordPress possible? Yes, in most situations it is possible and not very complicated. However you need to keep in mind two things:

  • use folder with CodeIgniter inside of WordPress system, NOT WordPress inside CodeIgniter and keep the folder name different than any WordPress slug for page name, post name, tag or category name etc.
  • avoid CodeIgniter controllers names the same like WordPress categories, tags or pages.

It means, that you can keep your CodeIgniter system at, for instance, https://www.fastsheep.com/interesting-pages/archive_listing where fastsheep.com points to your main folder for WordPress, interesting-pages is folder name and archive_listing is CodeIgniter controller name. It most probably will work as long as folder interesting-pages is not any page name, post name, tag, category name in the WordPress installation. In such situation, we have WordPress installed in https://www.fastsheep.com and CodeIgniter installed in interesting-pages folder. In most situations it will work without problems. If there are any collisions they would be due to some plugins incompatibility with such solution, but this is rather exception (but can happen).

However, to do it in opposite way, that is to try to set up WordPress installation inside CodeIgniter folder will produce, most probably, serious incompatibility issues. What you have inside CodeIgniter folder should be described only by CodeIgniter controllers and having WordPress installation folder as controller name will not work. And now we have problem – what will be the view: CodeIgniter view (PHP file) or WordPress? To cut it short – it will not work in most situations.

What is a good news is that you can easily integrate WordPress database with CodeIgniter system. It is very useful, if you require access to some CodeIgniter system zones via login and pair of username/password – you can use WordPress users details keeping in mind passwords encryption used by WordPress. But, such integration – from CodeIgniter point of view – will be based rather on calls to some bespoke WordPress API services via CURL, especially if you need authentication.

The general idea for CodeIgniter and WordPress integration is to make calls via CURL from CodeIgniter site, to WordPress site, send to WordPress site some data, on WordPress site port some API script process the data using WordPress functionality, and send back to CodeIgniter some data, if needed.

Trying to share some functionality between WordPress and CodeIgniter is rather very messy approach, expensive in maintenance, which can produce some unpredictable design problems, especially that the both framework evolve all the time. It is better to keep functionalities separately and let WordPress and CodeIgniter framework to do what they can do best.