Calling a WordPress query in a PHPBB theme template
-
I’m working on a site (localhost install) which requires several of the ‘promoted’ posts from the WordPress blog to be displayed at the top of the forum.
(This is literally the only interaction between WP and PHPBB, there’s no single sign-on or anything.)
I’m following the instructions listed here: https://codex.www.ads-software.com/Integrating_Wordpress_with_Your_Website
and here: https://wiki.phpbb.com/Tutorial.Template_syntax
As such, I’ve edited my theme’s overall_header.html file to include this at the top:
<!-- PHP --> define('WP_USE_THEMES', false); <!-- ENDPHP --> <!-- INCLUDEPHP ../wp-blog-header.php -->
Later, at the correct place in overall_header.html, I need to call the actual php file which contains the query, which I do so like so:
<!-- INCLUDEPHP ../wp-content/themes/mytheme/heroarea-secondary.php -->
But when I load the forum, I get a fatal error which causes the page to stop loading, with the following error message:
Fatal error: Call to a member function main() on a non-object in C:\Apache24\htdocs\test\wp-includes\functions.php on line 808
Now I know there’s not actually anything wrong with functions.php so I assume the issue is in my configuration, but I have no idea why it doesn’t work.
If I create a separate, standalone PHP file which just has this:
<?php define('WP_USE_THEMES', false); require('C:/Apache24/htdocs/test/wp-blog-header.php'); include('C:/Apache24/htdocs/test/wp-content/themes/mytheme/heroarea-secondary.php'); ?>
Then that works perfectly without any troubles and pulls the correct three posts from the ‘promoted’ category as desired. But as soon as I try and replicate it in PHPBB, I get errors.
Can anyone point me in the right direction? I don’t even honestly understand the error message I’m getting.
I’ve tried including wp-load.php and wp-config.php but neither make a difference.
- The topic ‘Calling a WordPress query in a PHPBB theme template’ is closed to new replies.