Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter + Wordpress integration

My website is designed with Wordpress. Some theme pages have a custom made PHP script for booking things, which I want to refactor in CodeIgniter, to get more flexibility. Questions :

1) how to use CI functions in WP with CI's routing system ? Do I have to make a CI page index.php/controller/page1/ and then call it in Wordpress ?

2) Do I have to use CodeIgniter "views" system or Wordpress "theme pages" to get my result ?

Thanks

like image 356
Marcandria Avatar asked Jul 24 '13 09:07

Marcandria


People also ask

Can I use CodeIgniter with WordPress?

But, the ease of management and updates on the CMS are too hard to give up, which is why many website owners today prefer to use CodeIgniter for application building. CodeIgniter is a lightweight PHP framework that can help in developing applications that can be integrated with WordPress, which I will explain shortly.

How do I link WordPress to CodeIgniter?

First step is to move CodeIgniter and the WordPress files in their own directory. After that, put the following line at the top of your CodeIgniter's index. php file. Change the path to wp-blog-header.

Which is better WordPress or CodeIgniter?

CodeIgniter rates 4.3/5 stars with 50 reviews. By contrast, WordPress.org rates 4.4/5 stars with 8,474 reviews. Each product's score is calculated with real-time data from verified user reviews, to help you make the best choice between these two options, and decide which one is best for your business needs.

What is CodeIgniter and WordPress?

CodeIgniter is a proven, agile & open PHP web application framework with a small footprint. It is powering the next generation of web apps. What is WordPress? A semantic personal publishing platform with a focus on aesthetics, web standards, and usability.


2 Answers

I used the following.

My goal is to use CodeIgniter for some pages, and leave the other pages in Wordpress untouched. I only have a few steps to do it :

Copy CI folder at the Wordpress root

Modify the « index.php » of CI to add an include which will add WP functions to CodeIgniter :

@require '../wp-load.php';
require_once BASEPATH.'core/CodeIgniter.php';

Once this line added, Wordpress functions will be usable in CodeIgniter ; they will be used mainly for views.

Modify the .htaccess of WP to not rewrite CI's URLs : After this line :

 RewriteRule ^index\.php$ - [L]

Add this line :

RewriteCond %{REQUEST_URI} !^/(codeigniter_folder|codeigniter_folder/.*)$

Then CI views can use WP functions.

like image 133
Marcandria Avatar answered Nov 04 '22 11:11

Marcandria


If you have an CI application that uses login session you have to modify the "load.php" file (from "wp-includes" WP folder). To do that follow the PhilB's answer from this link. For a complete explanation follow this post.

like image 30
PAdrian Avatar answered Nov 04 '22 10:11

PAdrian