I am using a wordpress site, but for a part of the site, I have decided that I will manually connect to the database and basically bypass wordpress for editing the database and retrieving results.
the problem is, when I include the WP header and footer, I am getting a blank page, viewing source gives an error although I have being unable to understand it.
This is the source code displayed for the page:
<!DOCTYPE html> <!--[if IE 6]> <html id="ie6" <br /> <font size='1'><table class='xdebug-error xe-fatal-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'> <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Fatal error: Call to undefined function language_attributes() in C:\wamp\www\thurston\wp-content\themes\twentyeleven\header.php on line <i>15</i></th></tr> <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr> <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr> <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0013</td><td bgcolor='#eeeeec' align='right'>388104</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\thurston\wp-content\themes\twentyeleven\editdb.php' bgcolor='#eeeeec'>..\editdb.php<b>:</b>0</td></tr> <tr><td bgcolor='#eeeeec' align='center'>2</td><td bgcolor='#eeeeec' align='center'>0.0024</td><td bgcolor='#eeeeec' align='right'>438352</td><td bgcolor='#eeeeec'>require( <font color='#00bb00'>'C:\wamp\www\thurston\wp-content\themes\twentyeleven\header.php'</font> )</td><td title='C:\wamp\www\thurston\wp-content\themes\twentyeleven\editdb.php' bgcolor='#eeeeec'>..\editdb.php<b>:</b>3</td></tr> </table></font>
Sorry for the jumble but that's all that is displayed.
The code for the actual page is this (linked to it as the code function on this site would not work):
https://dl.dropbox.com/u/10062971/editdb.php
And the wordpress header:
https://dl.dropbox.com/u/10062971/header.php
Adding to the database and then displaying the information from the database works on the main page, it's just clicking edit and going to the editdb.php page where the problems are.
Does anyone have any ideas?
language_attributes() is located in wp-includes/general-template.php.
You can't just include header.php and foter.php and hope for the best. you must include all dependencies.
Insert an anchortext in a page like [myAnchorText] use output buffering to catch the final HTML and replace the achor text:
<?php
// example from php.net
function callback($buffer) {
// replace all the apples with oranges
//or whatever logic you have
return (str_replace("[myAnchorText]", "oranges", $buffer));
}
ob_start("callback");
?>
<html><body>
<p>It's like comparing apples to oranges.</p>
</body></html>
<?php ob_end_flush(); ?>
/* output:
<html><body>
<p>It's like comparing oranges to oranges.</p>
</body></html>
*/