How to integrate WordPress template with CodeIgniter

前端 未结 5 2166
孤独总比滥情好
孤独总比滥情好 2020-11-28 21:37

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?

5条回答
  •  一个人的身影
    2020-11-28 22:31

    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.

提交回复
热议问题