WordPress.org

Ready to get started?Download WordPress

Forums

wp-blog-header.php (41 posts)

  1. carnold
    Member
    Posted 7 years ago #

    OK, can someone answer me this: to integrate external pages into your existing WP theme---add < ? php require('./wp-blog-header.php'); ? > to the external php file and of course make a call to the WP sidebar, header and footer? Does this not integrate a php file with your WP theme?

  2. vkaryl
    Member
    Posted 7 years ago #

    Sometimes. Depends on what you're trying to do, your host, and what other wp-specific stuff you put where.

  3. Austin Matzko
    Member
    Posted 7 years ago #

    Just calling wp-blog-header.php should do it; of course if your external file is in another directory you'll need to change the path to wp-blog-header.php to reflect that.

  4. vkaryl
    Member
    Posted 7 years ago #

    And that won't work at all if the file you want to call is on a different domain....

    As I said....

  5. carnold
    Member
    Posted 7 years ago #

    That's what i thought. I am trying to integrate a php page into my existing theme. I have no host, meaning i run the server and the WP install is at /doc_root and the php i am trying to integrate is at /doc_root/forum. I have made the path change in wp-blog-header.php to ../wp-blog-header.php. All are on the same domain. This is really strange why i can not get this php to integrate into my theme.
    When i include require('../wp-blog-header.php'); in between the opening < ? php and ending ? >, i get this error:
    Fatal error: Call to a member function on a non-object in /srv/www/htdocs/wp-includes/cache.php on line 206
    Wehn i put < ? require('wp-blog-header.php'); ? > in between the < head > tags, i get this error:
    Parse error: parse error in /srv/www/htdocs/forum/themes/head.php on line 11
    but it does show some of the page. Check it here:
    http://www.mytimewithgod.net/forum

  6. vkaryl
    Member
    Posted 7 years ago #

    Yah, that IS weird. Is something maybe screwy in your conf file?

    Maybe try hard-linking the wp-blog-header.php addy?

  7. carnold
    Member
    Posted 7 years ago #

    OK, that took the error away but it has to be outside of the beginning < ? php otherwise, the // of 'http:// comment out the rest of the hard-coded addy.
    Now when i add the call to get the header, i get this:
    Notice: Undefined variable: current_template_dir in /srv/www/htdocs/forum/themes/head.php on line 6

    Fatal error: Call to undefined function: get_bloginfo() in /srv/www/htdocs/wp-content/themes/bloxpress2/functions.php on line 20

  8. vkaryl
    Member
    Posted 7 years ago #

    Hmmm. That still sounds like something wonky in httpd.conf. You shouldn't be getting that as a comment. Are you using the right combo of single and double quotes?

    [Mind, I'm fishing here, because I haven't done this in dogs' years....]

  9. carnold
    Member
    Posted 7 years ago #

    I think so, i am using " and not ' (actually tried both and got that worked out). Now i get this error when < ? php include('http://dnsaddress.com/wp-content/themes/themname/functions.php'); ? >
    Fatal error: Call to undefined function: get_bloginfo() in /srv/www/htdocs/wp-content/themes/bloxpress2/functions.php on line 20
    I have made it further than before so i thank you for that :)
    I can post my httpd if needed.

  10. vkaryl
    Member
    Posted 7 years ago #

    Okay.... um. Are you USING functions.php for something? And what's your line 20 in that file?

    [If you post it tonight, hopefully someone else will have some ideas after looking it over - I'm about ready to be gone (had roofers here all day yesterday and today, as well as nasty t'storms - the noise has done me in!) I'll check tomorrow, maybe someone brighter than me will be along beforehand - LOTS of those around!]

  11. carnold
    Member
    Posted 7 years ago #

    Yes, using a functions.php file in the theme folder. Here is line 20 of said file:
    define( 'BP_BASEURL', get_bloginfo( 'template_directory' ) );
    Thanks for the help.

  12. carnold
    Member
    Posted 7 years ago #

    Just checking if anyone can help me?

  13. Austin Matzko
    Member
    Posted 7 years ago #

    Why are you directly including the functions.php file, and where are you doing it? Your theme's functions.php file will be automatically included.

  14. carnold
    Member
    Posted 7 years ago #

    Not sure why and where? What i do know is when i put in the call to get header (< ? php bp_get_header(); ? >) or anyother call to get sidebar, header or footer and the call is outside the opening < ? php, then it returns this error:
    Fatal error: Call to undefined function: bp_get_header() in /srv/www/htdocs/forum/themes/head.php on line 3
    So, i thought i would try to hardcode the functions.php into the file being integrated (which is head.php). Not sure if this answered your question?

  15. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    You don't need to include *anything* but the wp-blog-header file. Really. That loads everything you need, including the WordPress theme's functions.php file.

    The real question here is what in the heck is "bp_get_header()"? That is not a WordPress function. If it's something in the WordPress theme's functions.php, then it will get loaded as well, as long as you have WordPress setup to actually use that theme.

    It sounds like you're making this a lot more complicated than it really is. Does the blog itself actually work? If not, solve those problems first before trying to integrate it into something else.

  16. carnold
    Member
    Posted 7 years ago #

    That is what i thought. I use a theme called bloxpress 2 and bp_get_header()is that themes call to get the header and sidebar and footer. It is in the WordPress theme's functions.php; hnce the reason i was including it in the head.php file but even when i dont include it, i get the above error. The theme is active and it is a WP theme.
    Of course the blog works. I will be happy to send you the file i am trying to integrate so you could look at it, since i am making things harder than they are it might be easier if you look at it.

  17. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Okay then, your bp_get_header() call must come after the bit where you include the wp-blog-header.php file. That's really the most important thing here, the wp-blog-header must happen first. I'd just put that at the top of every file you need it in with a require_once() call.

  18. carnold
    Member
    Posted 7 years ago #

    Yep, that is the way i have it (so you can see it is not me making this harder than it seems). At the top of head.php i have:
    < ? php require_once('http://addy.com/wp-blog-header.php'); ? >
    then
    < ? php bp_get_header(); ? > and here is the error:
    Fatal error: Call to undefined function: bp_get_header() in /srv/www/htdocs/forum/themes/head.php on line 3
    You can see for yourself here http://www.mytimewithgod.net/forum

  19. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Whoa, you can't put in the full URL for a require like that. That very likely will not work at all.

    You either need to use a relative location, like "../wp-blog-header.php" or the full path, like "/home/users/you/whatever/wp-blog-header.php". Using the http stuff definitely will not work.

    If you get other errors from doing that, then we need to solve those errors. You can't work around them that way. All that does is not actually include the blog at all, which is why it appeared to solve your earlier problems.

  20. Austin Matzko
    Member
    Posted 7 years ago #

    You probably need to use the server path, not the web path in your require call. I.e not

    require_once('http://addy.com/wp-blog-header.php');

    but rather something like

    require_once('/srv/www/htdocs/wp-blog-header.php');

    [EDIT: Otto42 beat me to the draw]

  21. Austin Matzko
    Member
    Posted 7 years ago #

    Also, this post makes me think you might have another problem, because you seem to be including the functions.php file in the themname theme, but your active theme seems to be bloxpress2, judging from the error message.

  22. carnold
    Member
    Posted 7 years ago #

    The functions.php file is no longer included in the themname theme,

  23. carnold
    Member
    Posted 7 years ago #

    Alright, this is getting funny, lol. Here is the reason i did the full url:
    Fatal error: Call to a member function on a non-object in /srv/www/htdocs/wp-includes/cache.php on line 206
    when i have /srv/www/htdocs/wp-blog-header.php
    When it is hard coded with the full url, i do not get any errors. Of course, none of the sidebar, header or footer load either.

  24. Austin Matzko
    Member
    Posted 7 years ago #

    It might be possible that your forum software has a variable named $wpdb, which is messing up the WordPress object $wpdb. Or have you changed the wp-includes/wp-db.php file at all?

  25. carnold
    Member
    Posted 7 years ago #

    I have not changed that file at all, as far as i can remember.
    I also grep'ed thorugh the folders and files in /forum and $wpdb was not found in the forum software

  26. Austin Matzko
    Member
    Posted 7 years ago #

    What version of WordPress are you using? And what's on line 206 of /srv/www/htdocs/wp-includes/cache.php ?

  27. carnold
    Member
    Posted 7 years ago #

    Using 2.0.4 of WP. Line 206 of /srv/www/htdocs/wp-includes/cache.php:
    if ('options' == $group) {
    Line 205 else
    Line 207 $wpdb->hide_errors()

  28. Austin Matzko
    Member
    Posted 7 years ago #

    You're sure that within the forum directory you're not requiring anywhere else any other WordPress file than "wp-blog-header.php"?

    That just doesn't make any sense: before WP calls the functions in cache.php, it's already used the $wpdb object multiple times, so I don't understand why it suddenly becomes a "non-object."

  29. carnold
    Member
    Posted 7 years ago #

    The only other file i have modified was people.php, and this error was happening before i even found that file. I modd'ed that one to see if i was doing it right http://www.mytimewithgod.net/forum/people.php
    The head.php is the only other file that has been modified. And in that file i only have wp-blog-header.php, no functions.php nothing else (besides < ? php bp_get_header(); ? >). I can "undo" the people.php file, if you like but i assure you, this error was happening way before i modd'ed the people.php file. I can also send you the 2 files in question or grant direct access to the files.
    */Edit*
    Hmmmm, at the bottom of the people.php page, i see this:
    Warning: mysql_affected_rows() [function.mysql-affected-rows]: A link to the server could not be established in /srv/www/htdocs/wp-includes/wp-db.php on line 161
    But i can logon and navigate around without any problems. Weird

  30. Austin Matzko
    Member
    Posted 7 years ago #

    I'll look at anything you want to send me at if.website at gmail dot com.

    [EDIT: well, that might be your problem: connecting to the db server. If wp-db.php fails instantiate wpdb, then you'll get the other error.]

Topic Closed

This topic has been closed to new replies.

About this Topic