views:

1903

answers:

2

How can CodeIgniter and Wordpress be integrated such that the look and feel/template of the Wordpress blog is carried over to the CodeIgniter-created pages?

+6  A: 

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.php as needed to point to your wordpress's root directory.

<?php
require('../wp-blog-header.php');

Then, you can use the following functions inside your views:

<?
get_header();
get_sidebar();
get_footer();    
?>

Other helper functions can also be found in Wordpress's documentation which can assist you in integrating the design.

Click Upvote
+2  A: 

When I included the file wp-blog-header.php in Codeigniter's index.php page, I got a problem that site_url() is defined in both codeigniter's url helper and wordpress. I solved this using the following code.

require('blog/wp-blog-header.php');

add_filter('site_url', 'ci_site_url', 1);

function ci_site_url() {
    include(BASEPATH.'application/config/config.php');
    return $config['base_url'];
}

header("HTTP/1.0 200 OK");

Last line needs to be added as wordpress file was adding a http response header 'HTTP/1.0 404 Page not found' to the header.

Now its fine to use wordpress functions to call in Codeigntier.

sumanchalki
thanks . ............................................................................................:)
Click Upvote