I'm building a website that uses Wordpress as the CMS and is built with Yii framework. All the business logic works fine. Most visible pages are filled with content from Wordpress admin and only the user profile section is built with Yii.
My problem is that I would like to reuse the layout of the wordpress pages in the Yii app. Initially I tried to do it in a blank PHP file and everything worked as expected with this code:
<?php require( '/var/www/wordpress/wp-load.php' ); get_header(); ?> <div> some content here </div> <?php get_footer(); ?>
The problem is that when I make a new layout in Yii so that I can reuse the header and footer it crashes and displays blank page. I tried both with
require( '/var/www/wordpress/wp-load.php' );.
This is the code I use to load wordpress functionality in Yii but unfortunately it does not work.
<?php /* @var $this Controller */ spl_autoload_unregister(array('YiiBase','autoload')); require( '/var/www/wordpress/wp-load.php' ); get_header(); spl_autoload_register(array('YiiBase', 'autoload')); ?>
All I see is a completely blank page (no markup).
Any help would be much appreciated. Ideally I would like to use
get_footer() wordpress functions in Yii layouts/views.
I checked Apache logs and it seems that the following error is logged when I try to open the page in my browser:
PHP Fatal error: Call to a member function get() on a non-object in /var/www/wordpress/wp-includes/query.php on line 27
Also when I comment out the
get_header(); row the page opens without any errors (and without any styling too). So something prevents get_header() to work property in Yii.