Integrating a Wordpress query into a PHPBB theme template - wordpress

UPDATE: Managed to solve this by accident, answer is below.
I'm working on a site 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:
http://codex.wordpress.org/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 seperate, 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 the fatal error listed above.
Can anyone point me in the right direction?
I've tried including wp-load.php and wp-config.php but neither make a difference.

I actually just now managed to solve the issue.
The solution is to add
define('WP_USE_THEMES', false);
require('path/to/wp-blog-header.php');
To the bottom of common.php in the phpBB root directory.
Hope this helps anybody else in the future!

Related

Only the left menu toolbar is showing up on Wordpress admin

When I log in to my Wordpress admin, only the left menu toolbar is showing. Nothing else is displaying. The website front end works fine.
What I've done so far to investigate:
Renamed plugins folder to pluginz to make sure none of the plugins are doing this
Made sure there is no javascript error on the page
Made sure there is no 404 errors
Temporarily removed .htaccess to eliminate possible htaccess issues
Made sure there is no fatal php error thrown on admin
Any idea what might be going on?
I was able to fix the issue with help from here :
To fix the bug:
Open file blog/wp-admin/includes/screen.php in your favorite text editor.
On line 706 find the following PHP statement: <?php echo self::$this->_help_sidebar; ?>
Replace it with the statement: <?php echo $this->_help_sidebar; ?>
Save your changes.

Call to undefined function, get_settings wordpress

I have a Wordpress plugin with index.php that contains this line of code:
$plugindir = get_settings('home').'/wp-content/plugins/'.dirname(plugin_basename(__FILE__));
When I echo that code I get this output:
my.site.nl/wp-content/plugins/Tutorials
On the index page I also have a button that redirects to uploader.php,
inside uploader.php I have this code:
$plugindir = get_settings('home').'/wp-content/plugins/'.dirname(plugin_basename(__FILE__));
When I run the program I get an error that says:
Call to undefined function get_settings()
This error only applies on uploader.php, index.php works fine!
So it seems that I have to somehow let the uploader.php know that get_settings is a Wordpress function and it should recognize it, but I don't know how and I also don't know why the index page runs fine with the same code without including anything. I hope someone can help me out here.
index.php brings in all the WordPress functions as it loads. If you're loading another PHP file directly, you'll need to load in the WordPress functions by calling wp-load.php. See this answer (and the comments - you don't need to load all the files the answer mentions).
Try to use get_option('home') in place of get_settings('home') it may work.

Warning: Cannot modify header information when using require or require_once

I'm WordPress newbie.
I'm creating a plugin that redirect to custom login page each unregistered user access a website, let say the custom login page : custom_login.php.
I am able to create a code to redirect it but it seems no wordpress functions work in custom_login.php. So, I think I have to load something through the file. I guess wp-load.php.
Then I add some codes below at the top of the page :
<?php
require( 'd:\xampp\htdocs\wordpress\wp-load.php' );
?>
But then I got this error :
Warning: Cannot modify header information.....
I changed to require_once but still get similar error.
Some solutions of this forum threads advice to delete any whitespace. Frankly, I don't know what does it mean but I tried to delete all whitespace anyway so that the code become :
<?php require('d:\xampp\htdocs\wordpress\wp-load.php');?>
But it does not solve anything. The error is still exist.
Please help me, the expert ones.
Thanks in advance
Try inserting a system path relative to localhost, like this:
require( '/wp-load.php' ); // or just
require( 'wp-load.php' ); //
All depends on the location you are trying to include wp-load.php from.
On the other hand, you don't have to include wp-load.php if you place the file custom_login.php. in the stylesheet directory as a template or as a custom page. The way to do it is:
.1 Rename the file to page-custom-login.php
.2 Move the file to the stylesheet directory (The theme directory)
.3 Go to admin and create a new page with the title "custom login"
That's all. Now WP will treat that file as a single custom page.
They are correct - you have a space before the opening php tag in one of your files. It can be a bit tricky to find, but look hard.
If you can't find it, try looking for ob_clean() php function to help.

Slider stops loading pictures on a different page

I am building this site - http://www.bellated.us.lt/.
The problem is that the slider stops loading pictures for all other pages except for the main one. To see the problem you just have to press on any link from the menu. It is a wordpress system and all the code is added to the header.php. In fact, this file should be loaded properly always, not only for the main one.
Actually, I have no idea on how to solve this, so if you have any suggestions - please share.
Thanks.
You have a lot of network errors, like the following, on your page.
"NetworkError: 404 Not Found - http://bellated.us.lt/js/lightbox.js"
"NetworkError: 404 Not Found - http://bellated.us.lt/sample-page/slider1.jpg"
So probably your issue is caused by a path error, where you are referencing your files with incorrect relative paths. If so, these might help:
<?php get_stylesheet_uri() ?>
<?php get_template_directory_uri(); ?>
See:
get_stylesheet_uri
get template directory uri

Theming Webform in Drupal

I'm trying to theme my webform but I can't seem to get the new webform_form_#.tpl.php to load properly. When I go to the node page I get a blank page on firefox with an empty body.
So in Template.php i've added the following line (my webform is on node 4)
function phptemplate_webform_form_4 ($form) {
return _phptemplate_callback('webform_form_4', array('form' => $form));
}
I have a webform_form_4.tpl.php in my sites/all/theme/forest_floor/ directory which is a copy paste from the modules/webform/templates/webform-form.tpl.php
I've tried following the guide here, but I still get nothing when I visit the node page. Yes i've cleared the cache.
I've also tried removed everything in the webform_form_4.tpl.php and just added the
echo form_render($form); like between <?php ?> and I still get nothing.
Any suggestions?
A blank screen aka WSOD is properly due to a fatal PHP parse error. Try checking your apache error log.
The link you are following on drupal node/79086 is for the older v4 of drupal Maybe this can help you http://drupal.org/node/335020
Weird it won't let me login to reply (for some reason) it doesn't think i'm the one who wrote the question.
Checked the apache logs
PHP Fatal error: Call to undefined function _phptemplate_callback() in template.php
Am I calling an old function?

Resources